diff --git a/Example/Example.js b/Example/Example.js index 4c18e229c..c112e040c 100644 --- a/Example/Example.js +++ b/Example/Example.js @@ -65,7 +65,7 @@ const Example = () => { - + 1?_len5-1:0),_key5=1;_key5<_len5;_key5++){params[_key5-1]=arguments[_key5];} -_this.run.apply(_this,[ActionConst.POP_TO,routeName].concat(params)); +_this.run.apply(_this,[ActionConst.POP_TO,routeName,null].concat(params)); };this. -replace=function(routeName){for(var _len6=arguments.length,params=Array(_len6>1?_len6-1:0),_key6=1;_key6<_len6;_key6++){params[_key6-1]=arguments[_key6];} -_this.run.apply(_this,[ActionConst.REPLACE,routeName].concat(params)); +popAndPush=function(routeName){for(var _len6=arguments.length,params=Array(_len6>1?_len6-1:0),_key6=1;_key6<_len6;_key6++){params[_key6-1]=arguments[_key6];} +_this.run.apply(_this,[ActionConst.POP_AND_PUSH,routeName,null].concat(params)); };this. -reset=function(routeName){for(var _len7=arguments.length,params=Array(_len7>1?_len7-1:0),_key7=1;_key7<_len7;_key7++){params[_key7-1]=arguments[_key7];} +replace=function(routeName){for(var _len7=arguments.length,params=Array(_len7>1?_len7-1:0),_key7=1;_key7<_len7;_key7++){params[_key7-1]=arguments[_key7];} +var res=uniteParams(routeName,params); +_this.run(ActionConst.REPLACE,routeName,{key:routeName,index:0,actions:[_reactNavigation.NavigationActions.navigate({ +routeName:routeName, +params:res})]}); + +};this. + +reset=function(routeName){for(var _len8=arguments.length,params=Array(_len8>1?_len8-1:0),_key8=1;_key8<_len8;_key8++){params[_key8-1]=arguments[_key8];} var res=uniteParams(routeName,params); _this.run(ActionConst.RESET,routeName,{key:null,index:0,actions:[_reactNavigation.NavigationActions.navigate({ routeName:routeName, diff --git a/src/ActionConst.js b/src/ActionConst.js index 5499bc22e..0509c5c1f 100644 --- a/src/ActionConst.js +++ b/src/ActionConst.js @@ -11,3 +11,4 @@ export const RESET = 'REACT_NATIVE_ROUTER_FLUX_RESET'; export const FOCUS = 'REACT_NATIVE_ROUTER_FLUX_FOCUS'; export const BLUR = 'REACT_NATIVE_ROUTER_FLUX_BLUR'; export const ANDROID_BACK = 'REACT_NATIVE_ROUTER_FLUX_ANDROID_BACK'; +export const POP_AND_PUSH = 'REACT_NATIVE_ROUTER_FLUX_POP_AND_PUSH'; diff --git a/src/navigationStore.js b/src/navigationStore.js index eaab9275e..752b6f899 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -14,6 +14,7 @@ export const actionMap = { [ActionConst.REFRESH]: 'refresh', [ActionConst.RESET]: 'reset', [ActionConst.PUSH_OR_POP]: 'push', + [ActionConst.POP_AND_PUSH]: 'popAndPush', }; export const supportedActions = { @@ -22,6 +23,7 @@ export const supportedActions = { [ActionConst.BACK]: NavigationActions.BACK, [ActionConst.REFRESH]: NavigationActions.BACK, [ActionConst.RESET]: NavigationActions.RESET, + [ActionConst.REPLACE]: NavigationActions.RESET, }; function filterParam(data) { if (data.toString() !== '[object Object]') { @@ -193,7 +195,7 @@ class NavigationStore { if (nextScene === routeName) { this.setState(newState); } - } else if (type === ActionConst.REPLACE) { + } else if (type === ActionConst.POP_AND_PUSH) { this.pop(); this.push(routeName, ...params); } @@ -245,11 +247,19 @@ class NavigationStore { }; popTo = (routeName, ...params) => { - this.run(ActionConst.POP_TO, routeName, ...params); + this.run(ActionConst.POP_TO, routeName, null, ...params); + }; + + popAndPush = (routeName, ...params) => { + this.run(ActionConst.POP_AND_PUSH, routeName, null, ...params); }; replace = (routeName, ...params) => { - this.run(ActionConst.REPLACE, routeName, ...params); + const res = uniteParams(routeName, params); + this.run(ActionConst.REPLACE, routeName, { key: routeName, index: 0, actions: [NavigationActions.navigate({ + routeName, + params: res, + })] }); }; reset = (routeName, ...params) => {