Primitate
Primitate is a javascript library for managing state of your app by the only two methods.
Methods
- createAction: Create a function the only way to change the state.
- subscribe: Emit functions when state was changed by the Action.
Official packages
- react-primitate React binding
Install
npm install --save primitate
How to use
Case 1: Initial state is a primitive value or Array
/* import { Primitate } from "primitate" // ES2015 modules style */const Primitate = ;// ---------------------------// 1. Create Primitate Item// ---------------------------const Counter = ;// ---------------------------// 2. Create Action// ---------------------------{return x + 1;}const increment$ = Counter;// ---------------------------// 3. Subscribe// ---------------------------const unsubscribe =Counter;// ---------------------------// 4. Emit Action !!// ---------------------------;;// console.log: 2
Case 2: Initial state is an object
const Primitate = ; // ---------------------------// 1. Create Primitate Item// ---------------------------const Counter = ; // ---------------------------// 2. Create Action// --------------------------- { return x + 1;}const increment$ = Counter; // ---------------------------// 3. Subscribe// ---------------------------const unsubscribe = Counter; // ---------------------------// 4. Emit Action !!// ---------------------------;;// console.log({ count1: 2, count2: 0 });
Documentation
In preparation...
Lisence
MIT