petiole-immutable
v0.3.2
Published
Auto-immutability support to Petiole with Immutable.js
Downloads
6
Readme
petiole-immutable
Wraps state in Petiole store automatically to Immutable.js data structures.
See Immutable.js website for API details.
Usage
npm install petiole-immutable --save
import petiole from 'petiole';
import immutable from 'petiole-immutable';
const { declareLeaf, createStore } = petiole(immutable);
const items = declareLeaf({
initialState: {
list: [0, 1, 2],
},
actions: {
add: item,
},
reducer: {
add: (state, { item }) => state.list.push(item),
},
});
const store = createStore({ items });
const state = store.getState();
// Notice: only the leaf is a Collection - not the root node
const itemList = state.items.get('list');