Last active
February 25, 2020 00:43
-
-
Save csantiago132/0d2bc0b5e18fce613d70a6232f5ca42e 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
| // ... prev. code ommited | |
| export const combineReducer = (reducers) => { | |
| const globalState = {}; | |
| for (const [key, value] of Object.entries(reducers)) { | |
| // check it its a reducer | |
| if (typeof value === 'function') { | |
| globalState[key] = value(undefined, { type: '__@@PLACEHOLDER_ACTION__' }); | |
| } else { | |
| // let the developer know the value is not a reducer | |
| console.error(`${value} is not a function`); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment