Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* The router runs this navigate action once a new route is resolved.
* This returns a promise that must be satisfied before the render
* starts. The promise consists of all actions that each handler
* in the route declares that it needs before navigating.
*
* WHEN we upgrade react-router to 1.0, we should revisit this design
* https://github.com/rackt/react-router/pull/1158
*
* @return {Promise} to satisfy all the dependencies of the route
*/
navigate: (actionContext, payload) => {
actionContext.dispatch('CHANGE_ROUTE', payload);
var handlers = payload.routes.map((route) => route.handler);
var allActionDependencies = _(handlers.map((h) => h.navigateActionDependencies)).
chain().flatten().compact().value();
var allPromises = allActionDependencies.map(
// pass the payload from this navigate action
(action) => actionContext.executeAction(action, payload)
);
// navigation ready once all dependent promises are satisifed
return Q.all(allPromises);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.