2.0.1 • Published 6 years ago

redux-reducer-dsl v2.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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.

2.0.1

6 years ago

2.0.0

6 years ago

1.2.0

7 years ago

1.0.0

7 years ago