Skip to content

Commit

Permalink
feat(store): add shouldUpdateNodeFactory feature
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoGentile committed Apr 26, 2018
1 parent b6ba781 commit fe56b2c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/RouterStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {observable, action} from 'mobx';
import {observable, action, computed} from 'mobx';
import transitionPath, {shouldUpdateNode} from 'router5-transition-path';

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

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

setRouter(router) {
Expand Down Expand Up @@ -78,7 +78,12 @@ class RouterStore {
};

// Utility to calculate which react routeNode should update
shouldUpdateNode = shouldUpdateNode;
shouldUpdateNodeFactory = (nodeName) => {
return computed(() => {
return shouldUpdateNode(nodeName)(this.route, this.previousRoute);
});
};


}

Expand Down

0 comments on commit fe56b2c

Please sign in to comment.