@kraken97/restate
v3.2.2
Published
[![CircleCI](https://circleci.com/gh/zhDmitry/restate.svg?style=svg)](https://circleci.com/gh/zhDmitry/restate) [![NPM Downloads](https://img.shields.io/npm/dm/@kraken97/restate.svg?style=flat)](https://www.npmjs.com/package/@kraken97/restate)
Downloads
39
Readme
Restate
Into
This lib was created for reducing pain from redux boilerplaite.
- remove reducers and actions creators boilerplate
- remove boilerplate from binding actions, all actions are autbinded to their scope
- remove boilerplate from selecting hight level state, now to can use .select method on every reducer to select his state
- more sophisticated way for computed values which works without memoization (like mobx but more performat and without wrapping all the state into getters)
- more easier way for nested updates
- strictly typed and good test coverage
install
yarn add @kraken97/restate
how to use
doc soon see tree view example from redux
import { createActions, createState, build } from "@kraken97/restate";
const actions = createActions({
inc: build.plain
});
const countersState = createState([[0, 0, 0, 0]]);
// different types of counters
const state = createState({ counters: countersState });
state.on(actions.inc, (state, p) => {
return state + 1;
});
//[OPTIONAL] auto bind all actions to redux
// store is redux store
state.use(store.dispatch);
countersState.select(store.getState()); // will return state from root
// dispatch actions
// all actions are autobinded to store after using .use action
// you can assign one action to multiple stores
// to access plain action call inc.raw();
inc(1);
inc(2);
inc(2);
inc(3);
inc(8);
test coverage
-------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-------------------|----------|----------|----------|----------|-------------------|
All files | 93.02 | 86.11 | 87.37 | 93.08 | |
-------------------|----------|----------|----------|----------|-------------------|
todo
- improve types
- extend api with (comparators and computed see rfc.md)
- improve tests
- think about async actions