modelReducer(model, initialState)
Creates a modelReducer instance function that responds to these actions:
actionTypes.CHANGEactionTypes.RESET
and updates the state accordingly.
Arguments
model(String): A string representation of this model's path in the store.initialState(Any): The initial state of the model.
Returns
(Function): A reducer which updates the state in reaction to the above actions.
Notes
- The
modelprovided tomodelReducermust be the exact path in the state to the model. For most use-case scenarios, this is sufficient:
const initialUserState = {};
const store = createStore(combineReducers({
user: modelReducer('user', initialUserState),
}));
However, for deeper models, the full path string must be provided:
const initialUserState = {};
const store = createStore(combineReducers({
deep: combineReducers({
user: modelReducer('deep.user', initialUserState),
}),
}));