tiagofreres / create-reducer

Creates a reducer from an ActionHandlers object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

create-reducer

Creates a Redux reducer from an ActionHandlers object

build status npm version npm downloads

CreateReducer :: State a, ActionHandlers b, Action c => a,b -> (a,c -> a)

ActionHandlers :: ActionType a, State b, Action c => {a: (b,c -> b), ...}

Creates a reducer from an object that each property name is an actionType and its value is a function that receive a state and an action and return a new state

How to install

$ npm install redux-createreducer --save

Example:

import createReducer from 'redux-createreducer';

const initialState = 0;
const actionHandlers = {
	'INCREMENT': (state, action) => state + 1,
	'DECREMENT': (state, action) => state - 1
};

const reducer = createReducer(initialState, actionHandlers);

About

Creates a reducer from an ActionHandlers object


Languages

Language:JavaScript 100.0%