Skip to content

dvajs/dva-model-extend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dva-model-extend

npm package NPM downloads Dependency Status

Utility method to extend dva model.

Installation

npm install --save dva-model-extend

Usage

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',
  },
});

API

modelExtend(...models) => Model

Behaviour:

  • The model.namespace will be overrided by latter model.
  • model[state|subscriptions|effects|reducers] will be merged as Object.assign.
  • model.state will be overrided be latter model if it isn't an object.

License

MIT

About

Utility method to extend dva model.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published