What does everybody think about providing a higher-order reducer (i.e. reducer enhancer) for creating a model reducer on top of an existing reducer? Code would look something like this:
import { modellable } from 'react-redux-form';
// existing user reducer
import userReducer from './user-reducer';
// modellable: (reducer, model) => reducer'
export default modellable(userReducer, 'user');
This would create a reducer that:
Updates the state if the action is a RRF action (such as actions.change or actions.reset)
Pass the updated state to the original reducer, as well as the action
This can also simplify the updating of stores in existing projects to retrofit the model reducers:
What does everybody think about providing a higher-order reducer (i.e. reducer enhancer) for creating a model reducer on top of an existing reducer? Code would look something like this:
This would create a reducer that:
action
is a RRF action (such asactions.change
oractions.reset
)This can also simplify the updating of stores in existing projects to retrofit the model reducers:
This would not replace the existing
createModelReducer()
, which is quite useful when making new reducers.In case "modellable" is too awkward to spell (or, as it might turn out, probably not even a word), we can call the enhancer:
modeled()
asModel()
modelEnhancer()
model()
Just some ideas. Thoughts?