0.0.6 • Published 2 years ago

cubis v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
2 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

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago