chronicle icon indicating copy to clipboard operation
chronicle copied to clipboard

Tiny observable & high-performance state management.

chronicle

Tiny observable & high-performance state management with RxJS as first-class citizen.

NPM version Build Status

Installation

$ npm i chronicle@alpha --save

Usage

import { createStore } from 'chronicle';

const counter = (state = 0, action) => {
  switch (action.type) {
    case 'INCREMENT':
      return state + 1
    case 'DECREMENT':
      return state - 1
    default:
      return state
  }
}

const epic = (action$, store) =>
  action$
    .filter(action => action.type === 'DECREMENT')
    .map(() => ({ type: 'INCREMENT' }));

const store = createStore(counter, null, epic);

store.dispatch({ type: 'DECREMENT' });

// Will output 1 instead of -1
console.log(store.getState());

Credits

Thanks to Redux Observable for the initial inspiration and Forbes Lindesay for donating the chronicle npm name.

License

MIT © Robin van der Vleuten