mickeyjsx / mickey-model-extend

Utility method to extend mickey model.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mickey-model-extend

Utility method to extend mickey model.

MIT License

NPM Version Build Status Coverage Status NPM downloads Dependencies

Install

$ npm install --save mickey-model-extend

Usage

import modelExtend from 'mickey-model-extend';

const base = {
  state: {
    foo: null,
  },
  add: (state, payload) => state + payload,
};

const model = modelExtend(base, {
  namespace: 'foo.bar',
  state: {
    bar: 1,
  },
});

API

modelExtend(...models) => Model

Behaviour:

  • model.namespace will be overrided by latter model
  • model.createReducer will be overrided by latter model
  • model.state will be merged with Object.assign
  • model.state will be overrided by latter model if it isn't an object
  • model[subscriptions|enhancers] will be merged to a array
  • reducer functions will be merge with Object.assign

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

About

Utility method to extend mickey model.

License:MIT License


Languages

Language:JavaScript 100.0%