0.3.2 • Published 9 years ago

petiole-immutable v0.3.2

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

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