Created
May 15, 2016 00:47
-
-
Save camwest/e95564228344d7b82f2f4d1cd1ed508f 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
| function rootReducer(state, action) { | |
| return { | |
| part1: part1Reducer(state.part1, action), | |
| part2: part2Reducer(state.part2, action) | |
| } | |
| } | |
| function part1Reducer(state, action) { | |
| return { | |
| part1A: part1AReducer(state.A, action), | |
| part1B: part1BReducer(state.B, action) | |
| } | |
| } | |
| function part1AReducer(state, action) { | |
| return 'bar'; | |
| } | |
| function part1BReducer(state, action) { | |
| return 'baz' | |
| } | |
| function part2Reducer(state, action) { | |
| return 'foo'; | |
| } | |
| const state = {}; | |
| const action = {type: 'my action'}; | |
| const next = rootReducer(state, action); | |
| ` result looks like: | |
| { | |
| part1: { | |
| part1A: 'bar', | |
| part1B: 'baz' | |
| }, | |
| part2: 'foo' | |
| } | |
| ` | |
| // rootReducer knows about part1, part2 | |
| // part1 knows about part1A, part1B | |
| // this is a "top down" architecture |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment