New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chronicle

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chronicle

Tiny observable & high-performance state management

1.0.0
latest
Source
npm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

flux

FAQs

Package last updated on 26 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts