0.0.6 • Published 3 years ago

cubis v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Cubis

A state management that inspired on BLoC (Flutter)

import { createDescriptor, createAction } from 'cubis';
// defining a cubis with initial state = 1
const counterCubis = createDescriptor(1);
// defining cusbis's actions
// a cubis action retrieves context object. changing context.state prop to make cubis's state update
const incrementAction = createAction((context) => context.state++);
const decrementAction = createAction((context) => context.state--);

// creating a cubis instance
const counter$ = counterCubis.create();
// getting current state of cubis
console.log(counter$.state); // 1
// dispatch an action
counter$.dispatch(incrementAction);
console.log(counter$.state); // 2
counter$.dispatch(decrementAction);
console.log(counter$.state); // 1
0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago