Skip to content

Instantly share code, notes, and snippets.

@csantiago132
Last active February 25, 2020 00:43
Show Gist options
  • Save csantiago132/0d2bc0b5e18fce613d70a6232f5ca42e to your computer and use it in GitHub Desktop.
Save csantiago132/0d2bc0b5e18fce613d70a6232f5ca42e to your computer and use it in GitHub Desktop.
// ... 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