0.5.1 • Published 7 years ago

make-reducer v0.5.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 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

7 years ago

0.5.0

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago