Skip to content

Commit

Permalink
feat(Store): Add support for router5@6
Browse files Browse the repository at this point in the history
Add anew router5-transition-path utility function `shouldUpdateNode` to the store
  • Loading branch information
LeonardoGentile committed Apr 25, 2018
1 parent 7fd1830 commit b6ba781
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
55 changes: 27 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"babel-runtime": "^6.11.6",
"router5-transition-path": "5.0.0"
"router5-transition-path": "5.3.0"
},
"devDependencies": {
"babel-cli": "^6.16.0",
Expand All @@ -69,15 +69,15 @@
"mocha": "^3.1.2",
"rollup": "0.41.6",
"rollup-plugin-babel": "^2.7.1",
"router5": "^5.0.0",
"router5": "^6.1.2",
"semantic-release": "^15.1.7",
"semantic-release-conventional-commits": "^2.0.0",
"sinon": "^2.0.0-pre.3",
"sinon-chai": "^2.9.0",
"travis-deploy-once": "4.4.1"
},
"peerDependencies": {
"router5": "^5.0.0",
"router5": "^6.1.2",
"mobx": "^4.0.0"
},
"scripts": {
Expand Down
8 changes: 6 additions & 2 deletions src/modules/RouterStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {observable, action} from 'mobx';
import transitionPath from 'router5-transition-path';
import transitionPath, {shouldUpdateNode} from 'router5-transition-path';

class RouterStore {

Expand All @@ -16,6 +16,7 @@ class RouterStore {

constructor() {
this.navigate = this.navigate.bind(this);
this.shouldUpdateNode = this.shouldUpdateNode.bind(this);
}

setRouter(router) {
Expand Down Expand Up @@ -43,7 +44,7 @@ class RouterStore {
this.updateRoute('route', route);
this.updateRoute('previousRoute', previousRoute);
if (route) {
const {toActivate, toDeactivate, intersection} = transitionPath(route, previousRoute);
const {intersection, toActivate, toDeactivate} = transitionPath(route, previousRoute);
this.intersectionNode = opts.reload ? '' : intersection;
this.toActivate = toActivate;
this.toDeactivate = toDeactivate;
Expand Down Expand Up @@ -76,6 +77,9 @@ class RouterStore {
this.router.navigate(name, params, opts);
};

// Utility to calculate which react routeNode should update
shouldUpdateNode = shouldUpdateNode;

}

export default RouterStore;

0 comments on commit b6ba781

Please sign in to comment.