redux-reducer-dsl

2.0.1 • Public • Published

redux-reducer-dsl

Build Status

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.

Readme

Keywords

none

Package Sidebar

Install

npm i redux-reducer-dsl

Weekly Downloads

8

Version

2.0.1

License

MIT

Unpacked Size

97.3 kB

Total Files

8

Last publish

Collaborators

  • ryanaghdam