Statenano
Statenano is a small state handler with a fairly simple API, which exploits the potential of classes when managing states in an application.
Why use classes?
the classes offer a simple and minimalist inheritance, Statenano uses this to compose states based on classes.
yarn
yarn add -D statenano
npm
npm install -D statenano
Instancia
Statenano by default has a simple interface with 2 methods update and subscribe, update feeds the state with new properties and in turn notifies subscribers of each update.
; let initState = type: "sample" ; let state = initState;
initialState
as you noticed in the previous instance you can define an initial state as the first argument of State
instance.update([mixed objet])
allows subscribers to alert a change within the state
; let state = ; state; state;
instance.subscribe( function )
allows you to subscribe to a status update
Inheritance
Statenano to be a class facilitates the edition of behavior based on the inheritance
; { super; thistasks = ; } { this } { this } let state = ; state state;
Examples
Tipo | link |
---|---|
TODO | CodeSandbox |
SHOP | Productos - Bodeguita Agroecologica |
npm | git | uso |
---|---|---|
preact-statenano | preact-statenano | Is a small library that allows you to synchronize state events created on the basis of Statenano with components created with preact all thanks to the high order components. |