1.0.0 • Published 8 years ago
redux-create-reducer-curry v1.0.0
redux-create-reucer-curry
create fast, save, readability reducer with fp curry
install
npm i -S redux-create-reducer-curry
API
createReducer(initState: any)(actions: obj)
- initState
- default: {}
- reducer init state
- actions
- default: {}
- a plain obj with function for action
- key is action type, val is action to change reducer
- function: (state, action) => {}
- state: the reducer state
- action: the action
- @return reducer function
- reducer for redux
usage
import createReducer
// reducer
export default createReducer({isDemo: true})({
TOGGLE: (state, action) => ({isDemo: !state.isDemo})
})
// action
function toggle(){
return {
type: 'TOGGLE'
}
}
1.0.0
8 years ago