Created
July 22, 2015 12:55
-
-
Save tadjik1/db46a0de49eb448cbf4f to your computer and use it in GitHub Desktop.
implement custom subscription on redux store
This file contains 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
const initialTodosState = []; | |
const initialCounterState = 0; | |
function todos(state = initialTodosState, action) { | |
return state; | |
} | |
function counter(state = initialCounterState, action) { | |
return state; | |
} | |
const reducer = combineReducers({ todos, counter }}); | |
const store = createStore(reducer); | |
// right now my store structure looks like: | |
// store.getState() => | |
// { | |
// todos: [...], | |
// counter: 0 | |
// } | |
// how could I subscribe on update only `todos` subtree or `counter`? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the default method
store.subscribe(handler)
allows to sibscribe only on root (my handler will be invoked after every changes,counter
andtodos
)