redux-reducer-dsl
v2.0.1
Published
Define Redux reducers with a DSL
Downloads
9
Readme
redux-reducer-dsl
Define Redux reducers with a doman-specific language.
import reducer from 'redux-reducer-dsl';
const counterReducer = reducer(r => {
r.action('RESET', (state, action) => { value: 0; });
r.action('INCREMENT', (state, action) => { value: state.value + 1 });
r.action('DECREMENT', (state, action) => { value: state.value - 1 });
});
The type can also be a function that returns a boolean:
import reducer from 'redux-reducer-dsl';
const counterReducer = reducer(r => {
r.action('INCREMENT', (state, action) => { value: state.value + 1 });
r.action('DECREMENT', (state, action) => { value: state.value - 1 });
r.action(
type => type !== 'INCREMENT' && type !== 'DECREMENT',
(state, action) => { value: 0; }
);
});
Changelog
v2.0.1: Adds ESLint to project
v2.0.0: Rewrite with ES6. Support function predicate for action type
v1.1.0: Adds integration tests.
v1.0.0: Initial prototype.