Created
November 11, 2019 20:49
-
-
Save evgenyfedorenko/21e131426e39a842eb603d545ffba9b2 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 reducerFactory(reducers) { | |
return function combination(state, action) { | |
const nextState: any = {}; | |
const reducerKeys = Object.keys(reducers); | |
for (let i = 0; i < reducerKeys.length; i++) { | |
const key = reducerKeys[i]; | |
const reducer: any = reducers[key]; | |
nextState[key] = reducer(state[key], action); | |
} | |
return nextState; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment