Skip to content

Instantly share code, notes, and snippets.

@arackaf
Last active September 4, 2017 18:29
Show Gist options
  • Select an option

  • Save arackaf/83a8618cb16c1560993c1bcb89625e3a to your computer and use it in GitHub Desktop.

Select an option

Save arackaf/83a8618cb16c1560993c1bcb89625e3a to your computer and use it in GitHub Desktop.
const combineLazyReducers = (reducers, initialState) => {
let reducerKeys = new Set(Object.keys(reducers));
Object.keys(initialState)
.filter(k => !reducerKeys.has(k))
.forEach(k => {
reducers[k] = state => state === undefined ? null : state
});
return combineReducers(reducers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment