Skip to content
Utility method to extend dva model.
Branch: master
Clone or download
Latest commit 69bfa33 Oct 17, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src bump 0.1.2 Oct 17, 2017
test chore: add warning for overrided fields, close: #2 Oct 17, 2017
.gitignore chore: add warning for overrided fields, close: #2 Oct 17, 2017
.travis.yml chore: add CI Dec 30, 2016
LICENSE
README.md docs: add API section Dec 30, 2016
package.json bump 0.1.2 Oct 17, 2017

README.md

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

You can’t perform that action at this time.