0.5.1 • Published 9 years ago

make-reducer v0.5.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

npm version Build Status codecov.io Total downloads

make-reducer

Functions to easily build redux reducers without boilerplate code.

Counter example

const initialState = 0;
const reducer = makeReducer(initialState);

const increment = reducer.on('INCREMENT', (counter) => counter + 1);
const decrement = reducer.on('DECREMENT', (counter) => counter - 1);

const store = createStore(reducer, initialState);

store.dispatch(increment());
store.dispatch(decrement());

You can use named functions to define actions.

const initialState = 0;
const reducer = makeReducer(initialState);

const increment = reducer.on(function INCREMENT(counter) { return counter + 1; });
const decrement = reducer.on(function DECREMENT(counter) { return counter - 1; });

const store = createStore(reducer, initialState);

store.dispatch(increment());
store.dispatch(decrement());
0.5.1

9 years ago

0.5.0

9 years ago

0.4.5

9 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago