Reactivity
As the name says, Reactivity is a lightweight javascript library to create simple reactive objects. Inspired in Redux and Vuex
Get started
NPM:
Then...
CDN:
Usage
First, Reactivity
must be instantiated
The Reactivity
constructor receives one paramater, an options
parameter, which needs to receive all the data, middlewares and callbacks. For example...
About options
properties...
data
is required, each of its properties must have two sub-properties,type
andvalue
. This last one is optional, buttype
is required, it must be a build-in object constructor, like String, Boolean, Array...beforeUpdating/updated
, could be functions or objects (with functions of course), the parameter is the current state of thedata
middlewares
property has two sub-properties,setters
andgetters
, each function defined in both properties receives the same parameters of a Proxyget
andset
traps and must return a boolean, otherwise it will fail
Actions
For set a property...
For get a property...
All these actions will trigger all callbacks, either beforeUpdating/updated
and middlewares