Setup#

The Rebased state is built upon reduxjs providing the necessary foundation for working with memoized data.

Install#

npm install @rebased/state @rebased/core

Configure#

import { install, createReducer } from '@rebased/state';
const counter = createReducer(0, {
increment: (state, action) => state + action.payload,
decrement: (state, action) => state - action.payload
});
install({
// enables Redux devTools
// https://bit.ly/2ACP7QY
production: false,
// trace source of state changes
// more options at https://bit.ly/3fu7vKU
trace: true,
// initial state
state: {
counter: 420
},
reducers: {
counter
}
});

Example#

import { dispatch } from '@rebased/state';
// increment counter by 10
dispatch({
type: 'increment',
payload: 10
});