Skip to content

unirakun/k-mst-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k-mst-router

Make a Router from mobx-state-tree model !

CircleCI Coverage Status NPM Version Size

Contents

Purpose

TODO

Why

TODO

Installation

  • yarn add k-mst-router
  • npm i --save k-mst-router

API

  1. Import the Model from k-mst-router: import Router from 'k-mst-router'
  2. Use it to one of your model, and initialize it with a preProcessSnapshot :
  import { types } from 'mobx-state-tree'
  import Router from 'k-mst-router'

  export default types
    .model({
      router: Router,
    })
    .named('Store')
    .preProcessSnapshot(snapshot => ({
      ...snapshot,
      router: {
        screens: [
          {
            name: 'list',
            path: '/',
          },
          {
            name: 'new',
            path: '/new',
          },
          {
            name: 'authentication',
            path: '/login',
          },
          {
            name: 'edit',
            path: '/contacts/:id',
          }
        ],
      },
    }))
  1. Change routes with go action: store.router.go('new')
  2. It supports parameters: store.router.go('edit', { id: 3 })

About uni rakun

uni rakun is created by two passionate french developers.

Do you want to contact them ? Go to their website

Guillaume CRESPEL Fabien JUIF

Releases

No releases published

Packages

No packages published