Share Data Representations (Models, Collections) Node and the Browser
Read the DOCS
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.
Metamon is available via npm
for Node, for the Browser via CDN, and bower
<script src="https://cdn.jsdelivr.net/npm/metamon@2.0.0/dist/metamon.cjs.js" integrity="sha256-i1uYcaeoV21xNqcjFyXpSaaHRc5o7unpCi+lPHmntA4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/metamon@2.0.0/dist/metamon.js" integrity="sha256-W0RVLgpssC2x6SaACzqDiIa1Xo1L6L1vVmawPO9+2lE=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/metamon@2.0.0/dist/metamon.min.js" integrity="sha256-yrlSk0MzJQD8GU0I0MYXnPUxrJ5Jxs6FvvYLLvpfht8=" crossorigin="anonymous"></script>
npm i -S metamon
You can install metamon via bower with:
bower install metamon
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
}
}