metamon
v2.6.2
Published
model, and collection library for class based or pojo models
Downloads
9
Maintainers
Readme
Metamon
Share Data Representations (Models, Collections) Node and the Browser
Read the DOCS
Why?
Metamon is a toolkit for consistency with the representations of your data between Node applications and Browsers. It provides methods for creating, indexing, manipulating, and maintaining consistency with the representations.
Installation
Metamon is available via npm
for Node, for the Browser via CDN, and bower
jsDelivr CDN
Minified
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/metamon.cjs.js" integrity="sha256-i1uYcaeoV21xNqcjFyXpSaaHRc5o7unpCi+lPHmntA4=" crossorigin="anonymous"></script>
Un-Minified
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/metamon.js" integrity="sha256-W0RVLgpssC2x6SaACzqDiIa1Xo1L6L1vVmawPO9+2lE=" crossorigin="anonymous"></script>
CommonJS
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/metamon.min.js" integrity="sha256-yrlSk0MzJQD8GU0I0MYXnPUxrJ5Jxs6FvvYLLvpfht8=" crossorigin="anonymous"></script>
Node
npm i -S metamon
Browser
You can install metamon via bower with:
bower install metamon
Using in Redux
Using ES6 Classes as state really don't play well with Redux. SEE: Why Not to Store Objects In Redux
import {Model} from 'metamon/index.es6.js';
class PersonCollection extends Model {}
// inside a reducer
switch(action.type) {
case 'LOAD_USERS': {
return new PersonCollection(action.users, User).toArray();
}
default: {
return state
}
}