Skip to content

Instantly share code, notes, and snippets.

@tomchentw
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save tomchentw/ba4d986e2733bed43e21 to your computer and use it in GitHub Desktop.

Select an option

Save tomchentw/ba4d986e2733bed43e21 to your computer and use it in GitHub Desktop.
Redux-Universal - Code Sections - 4
// http://git.io/v3OGo
function fetchData (dispatch, forumId) {
return dispatch(PostActions.getPostList(forumId));
}
@createEnterTransitionHook(store => (state/*, transition */) => {
const { AppReducer, PostReducer } = store.getState();
// load different forum based on our url.
const { forumId } = state.params;
if (AppReducer.fetchForServerRendering) {
return fetchData(store.dispatch, forumId);
}
// the business logic part to load data based on our url
if (!PostReducer.hasIn(["postIdsByForumId", forumId])) {
return fetchData(store.dispatch, forumId);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment