Methods
(static) createReducer(switches, initialStateopt, extentionsopt, optionsopt) → {function}
Create reducer by types hash
...
createReducer({
'@@user/ADD_PHOTO': function(state, action) {
return { ...state, photo: action.photo }
},
//...
}, initialUserState);
...
createReducer({
[TYPES.ADD_PHOTO](state, action) {
return { ...state, photo: action.photo }
},
//...
}, initialUserState, null, { set: TYPES.SET });
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
switches |
Object | hash with type => reducer values | ||
initialState |
Mixed |
<optional> |
null | initial state |
extentions |
Object |
<optional> |
null | sub hash with field name => reducer values for inner fields reducing |
options |
Object |
<optional> |
null | options, set: SET_TYPE, reset: RESET_TYPE for auto create SET and RESET reducers |
- Source:
Returns:
reducer
- Type
- function
(static) getResetReducer(initialState) → {function}
return reset reduser, for reset state
Parameters:
Name | Type | Description |
---|---|---|
initialState |
Object | initial state for reducer |
- Source:
Returns:
reset reducer
- Type
- function
(static) getSetReducer(initialState) → {function}
return set reducer with auto-reset logic
Parameters:
Name | Type | Description |
---|---|---|
initialState |
Object | initial state for reducer |
- Source:
Returns:
set reducer
- Type
- function