async-reactivity
v2.0.26
Published
This library is inspired by Vue.js implementation of reactivity. You can familiarize with the concept of reactivity [here](https://vuejs.org/guide/extras/reactivity-in-depth.html). Short excerpt:
Downloads
441
Readme
Purpose
This library is inspired by Vue.js implementation of reactivity. You can familiarize with the concept of reactivity here. Short excerpt:
Reactivity is a programming paradigm that allows us to adjust to changes in a declarative manner.
However Vue.js reactivity is limited to synchronous computation. This library solves this limitation and supports both - synchronous and asynchronous computation.
You can familiarize with sample use here.
Concepts
We refer to values of many variables as "state".
We refer to values of many reactive variables as "reactive state".
For reactive state to be reactive dependencies need to be tracked. So it is easier to think about reactive state as a dependency graph (for example A → B → C). Here A → B means:
- A depends on B
- B is dependency
- A is dependent
There are few types of reactive variables:
- ref
- simply stores a given value (Vue.js
shallowRefequivalent) - can only be dependency (only incoming arrows)
- simply stores a given value (Vue.js
- computed
- defined by pure function (Vue.js
computedequivalent) - can be both - dependent and dependency (incoming and outgoing arrows)
- defined by pure function (Vue.js
To integrate state with reactive state you can use:
- listener
- inherits
ref- can only be dependency (only incoming arrows)
startfunction is called when listener gets first dependent- it ensures value is updated
stopfunction is called when listener loses last dependent
- inherits
- watcher
- a function that is called when dependency changes
- can only be dependent (only outgoing arrows)
Behavior
You can familiarize with behavior by reading tests.
