Coder Social home page Coder Social logo

chronicle's Introduction

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

chronicle's People

Contributors

robinvdvleuten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chronicle's Issues

Make subscribers compatible with redux middleware

The current middleware implementation of flucon looks like this;

store(() => (action, next) => {
  return next(action);
});

But should look like the following to be more compatible with redux;

store(() => next => action => {
  return next(action);
});

Unable to add operations to action$ subject

When importing this module, you aren't able to add operators to the action$ subject instance;

import { createStore } from 'chronicle';
import { Subject } from 'rxjs/Subject';

// Add the filter operator as mentioned by the docs.
import 'rxjs/add/operator/filter';

const reducer = (state = 0, action) => {
  return state;
}

const rootEpic = (action$) => {
  // Why is action$.filter undefined here? 
  console.log(action$.filter, Subject.prototype.filter);

  return action$;
}

const store = createStore(reducer, undefined, rootEpic);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.