项目作者: unirakun

项目描述 :
mobx-state-tree router model
高级语言: JavaScript
项目地址: git://github.com/unirakun/k-mst-router.git
创建时间: 2018-01-05T10:05:06Z
项目社区:https://github.com/unirakun/k-mst-router

开源协议:MIT License

下载


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 :

    1. import { types } from 'mobx-state-tree'
    2. import Router from 'k-mst-router'
    3. export default types
    4. .model({
    5. router: Router,
    6. })
    7. .named('Store')
    8. .preProcessSnapshot(snapshot => ({
    9. ...snapshot,
    10. router: {
    11. screens: [
    12. {
    13. name: 'list',
    14. path: '/',
    15. },
    16. {
    17. name: 'new',
    18. path: '/new',
    19. },
    20. {
    21. name: 'authentication',
    22. path: '/login',
    23. },
    24. {
    25. name: 'edit',
    26. path: '/contacts/:id',
    27. }
    28. ],
    29. },
    30. }))
  3. Change routes with go action: store.router.go('new')
  4. 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