@markorusic/create-reducer
v1.3.0
Published
Helper for creating clean, readable, boilerplate free reducers
Downloads
1
Readme
@markorusic/create-reducer
Create cleaner, more readable, boilerplate-free reducers applicable to any JavaScript environment.
Install
$ npm i @markorusic/create-reducer
Usage
import createReducer from '@markorusic/create-reducer'
const initialState = { count: 0 }
const actionTypes = {
increment: 'increment',
decrement: 'decrement'
}
const counterReducer = createReducer({
[actionTypes.increment]: state => ({
count: state.count + 1
}),
[actionTypes.decrement]: state => ({
count: state.count - 1
})
}, initialState)