reduce-merge-reducers
v0.2.3
Published
Reduce and merge multiple reducers into a single reducer supporting initial state
Downloads
10
Maintainers
Readme
reduce-merge-reducers
Reduce multiple reducers into a single reducer from left to right and merge their initial states.
:warning: in order to avoid unexpected results one should use plain objects as initial states
npm install --save reduce-merge-reducers
Example
const reducer = reduceMergeReducers(
(state = { C: 3 }) => state,
(state = { D: 5 }) => state,
);
expect(reducer(undefined)).to.deep.equal({ C: 3, D: 5 });
Why?
This package is a variant of reduce-reducers supporting initial state. The implementation is based on naorye suggestion regarding the following issue https://github.com/acdlite/reduce-reducers/issues/9