petiole-immutable

0.3.2 • Public • Published

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');

Readme

Keywords

Package Sidebar

Install

npm i petiole-immutable

Weekly Downloads

0

Version

0.3.2

License

MIT

Last publish

Collaborators

  • ilkkahanninen