Last active
July 8, 2016 10:27
-
-
Save kazagkazag/e095fcd8bb71880b4827ac24d3d55634 to your computer and use it in GitHub Desktop.
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
| /* | |
| expected state: | |
| { | |
| accounts: { | |
| items: [] | |
| isFetching: boolean | |
| fetchingErrorMessage: string | |
| } | |
| } | |
| */ | |
| // accountReducers.js | |
| function accounts() {} | |
| function isFetching() {} | |
| function fetchingErrorMessage() {} | |
| export default combineReducers({ | |
| items: accounts, | |
| isFetching, | |
| fetchingErrorMessage | |
| }); | |
| //combineReducers is from react-redux library, result is the same as here: | |
| export default function (state = {}, action) { | |
| return { | |
| items: accounts(state.accounts.items, action), | |
| isFetching: isFetching(state.accounts.isFetching, action), | |
| fetchingErrorMessage: fetchingErroMessage(state.accounts.fetchingErrorMessage, action) | |
| }; | |
| } | |
| // rootReducer.js | |
| // import accountReducers from "accountReducers.js" | |
| export default combineReducers({ | |
| accounts: accountReducers | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment