Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.17 KB

README.md

File metadata and controls

48 lines (39 loc) · 1.17 KB

redux-eventually

Build Status npm npm

Redux-eventually facilitates using CRDTs inside of the redux store. This library consists of factory methods for easier usage with these otherwise quite cumbersome data-structures.

Example Counter

import { createCounterAction, createCounterReducer, createCounterSelector } from "redux-eventually";

const COUNTER = "COUNTER";

export countAction = createCounterAction(COUNTER);
/*
{
  type: COUNTER,
  payload: {
    id: "adam",
    value: 1
  }
}
*/

export counterReducer = createCounterReducer();
/*
{
  type: "pn-counter",
  p: {
    adam: 1,
    gustav: 0
  },
  n: {
    adam: 1,
    gustav: 1
  }
}
*/

export counterSelector = createCounterSelector();

let store = createStore(todosReducer);
const state = todosReducer(countAction("adam", 1));
const todos = todosSelector(state);