Skip to content

Instantly share code, notes, and snippets.

@nelix
Created February 18, 2015 09:05
Show Gist options
  • Save nelix/1b28dd2d7118163629a7 to your computer and use it in GitHub Desktop.
Save nelix/1b28dd2d7118163629a7 to your computer and use it in GitHub Desktop.
Router.run(routes, Router.HistoryLocation, (Handler, state) => {
function render() {
var data = flux.stores.getAll();
React.render(<Handler state={state} data={data} actions={flux.actions}/>, container);
}
_.each(state.routes, route => {
if (Array.isArray(route.handler.actions) { // handle all the fetching... or other static actions...
_.each(route.handler.actions, action => setTimeout(action.bind(null, state.params)));
}
});
stores.onAll('change', () => render());
render();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment