Last active
August 29, 2015 14:27
-
-
Save tomchentw/ba4d986e2733bed43e21 to your computer and use it in GitHub Desktop.
Redux-Universal - Code Sections - 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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