1.0.0 • Published 6 years ago

smallorange-unistore-batch-reducers v1.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

CircleCI

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}
	});