Utility method to extend dva model.
npm install --save dva-model-extend
import modelExtend from 'dva-model-extend';
const human = {
state: {
stomach: null,
},
reducers: {
eat(state, { payload: food }) {
return { ...state, stomach: food };
},
},
};
const benjy = modelExtend(human, {
namespace: 'human.benjy',
state: {
name: 'Benjy',
},
});
Behaviour:
- The
model.namespace
will be overrided by latter model. model[state|subscriptions|effects|reducers]
will be merged asObject.assign
.model.state
will be overrided be latter model if it isn't an object.
MIT