https://github.com/mickeyjsx/mickey-model-extend
Utility method to extend mickey model.
https://github.com/mickeyjsx/mickey-model-extend
framework mickey model utility
Last synced: 6 months ago
JSON representation
Utility method to extend mickey model.
- Host: GitHub
- URL: https://github.com/mickeyjsx/mickey-model-extend
- Owner: mickeyjsx
- License: mit
- Created: 2017-09-15T03:49:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-21T07:06:09.000Z (over 8 years ago)
- Last Synced: 2025-03-22T01:37:48.147Z (about 1 year ago)
- Topics: framework, mickey, model, utility
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mickey-model-extend
> Utility method to extend mickey model.
[](https://github.com/mickeyjsx/mickey-model-extend/blob/master/LICENSE)
[](https://www.npmjs.com/package/mickey-model-extend)
[](https://travis-ci.org/mickeyjsx/mickey-model-extend)
[](https://coveralls.io/r/mickeyjsx/mickey-model-extend)
[](https://npmjs.org/package/mickey-model-extend)
[](https://david-dm.org/mickeyjsx/mickey-model-extend)
## Install
```
$ npm install --save mickey-model-extend
```
## Usage
```es6
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](https://github.com/mickeyjsx/mickey-model-extend/issues/new).