Created
September 8, 2020 07:06
-
-
Save perjo927/1e67f110eabd392d54b5672a831a0f2b to your computer and use it in GitHub Desktop.
Make dispatcher
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
export const makeDispatcher = (stateHandlers, reducer, onDispatch) => ({ | |
dispatch(action) { | |
const { getState, setState } = stateHandlers; | |
const state = getState(); | |
const newState = reducer(state, action); | |
setState(newState); | |
onDispatch(); | |
return action; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment