Fundamentals
Last updated
Was this helpful?
Last updated
Was this helpful?
ActiveJS has 4 fundamental types of constructs, , , , and . All these constructs are Observables since they extend RxJS' Observable class.
You don't need to learn all of them to start using ActiveJS; and can be used independently without any further understanding of or . Also, ActiveJS is tree-shakeable, hence the parts that you don't use, will not get bundled in your build.
This data-flow diagram might give you some perspective before we dive into details. It shows how ActiveJS is connected with other parts of a Web app. All parts of an App can communicate with any instance of an ActiveJS construct directly, there is no abstraction layer involved like a Store, Dispatcher, Middleware, or Reducer.
Every state management solution relies on a robust storage system, and for that exact purpose, ActiveJS has independent, reactive storage Units. Simply called Units.
Units emulate JavaScript's native data structures. There's a specialized type of Unit for each of the most used native data structures. All the Units are also Observables
.
Reactive storage Systems help with async APIs like XHR and fetch or any third party abstraction.
Our setup is complete, now we can easily share query
, data
, error
and pending-status
with different parts of our App.
Now, all we need to do is trigger a new API request, which also can be done from anywhere, like this:
Actions help trigger customized operations in a reactive fashion.
It creates a master Observable of combined values of provided members of the Cluster.
It also provides direct access to its members and their combined value.
is a boolean
counterpart, it stores and provides a boolean
value at all times.
is a number
counterpart, it stores and provides a number
value at all times.
is a string
counterpart, it stores and provides a string
value at all times.
is an array
counterpart, it stores and provides an array
value at all times.
is loosely based on Map
, it stores and provides a simple object
value at all times.
doesn't pertain to any specific data type, it's generic in nature, it can store any type of value.
A System is just a systematic combination of one or more with pre-configured inter-relationships.
For example, can be used to store, share, replay, and wait for async tasks. This is realized by utilizing four Units for every aspect of an async task, it includes three , one each for query
, response
and error
, and one for the pending-status
of an async task.
Actions are meant to represent unique reactive events. Action is an RxJS like construct, it also extends RxJS Observable, and implements custom features like replay on demand.
A Cluster is a wrapper of two or more , , , or even . It's intended to be used to create a group of several ActiveJS instances.