smallorange-unistore-batch-reducers

1.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i smallorange-unistore-batch-reducers

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

23 kB

Total Files

6

Last publish

Collaborators

  • feliperohde