smallorange-unistore-batch-reducers
v1.0.0
Published
[![CircleCI](https://circleci.com/gh/feliperohdee/smallorange-unistore-batch-reducers.svg?style=svg)](https://circleci.com/gh/feliperohdee/smallorange-unistore-batch-reducers)
Downloads
4
Readme
Simple batch reducers for https://github.com/developit/unistore
Sample
const store = unistore.createStore({
a: 1,
b: 2
});
const reducers = {
one: (state, add = 1) => ({
a: state.a + add,
b: state.b + add
}),
two: (state, add = 1) => Promise.resolve({
a: state.a + add,
b: state.b + add
}),
three: () => null,
four: () => Promise.resolve(null),
};
batchReducers(store, [
reducers.one, 2
], [
reducers.two, 2
],
reducers.three,
reducers.four
)
.then(state => {
// state === {a: 5, b: 6}
});