1.0.0 • Published 6 years ago

chronicle v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

chronicle

Tiny observable & high-performance state management.

Build Status

Installation

$ npm i chronicle --save

Usage

import chronicle, { thunk } from 'chronicle';

const ACTIONS = {
  INCREMENT: state => ({ counter: state.counter + 1 }),
  DECREMENT: state => ({ counter: state.counter - 1 }),
};

const store = chronicle(
  (state = { counter: 0 }, action) =>
    action && ACTIONS[action.type]
      ? ACTIONS[action.type](state, action)
      : state
);

store(thunk());

const unsubscribe = store(({ dispatch }) => next => action => {
  console.log(action);
  return next(action);
});

store.dispatch(dispatch => dispatch({ type: 'INCREMENT' }));

unsubscribe();

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

console.log(store.getState());

Performance

You can run the performance test through npm run test:perf;

chronicle x 892,393 ops/sec ±4.99% (66 runs sampled)
chronicle with thunk x 332,470 ops/sec ±3.61% (49 runs sampled)
redux x 557,308 ops/sec ±1.63% (89 runs sampled)
redux with thunk x 288,050 ops/sec ±1.25% (90 runs sampled)
Fastest is chronicle

Credits

Thanks Forbes Lindesay for donating the chronicle npm name.

License

MIT © Robin van der Vleuten

2.0.0-alpha.1

6 years ago

1.0.0

7 years ago

0.1.0

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago