Each ConanJs state object has a a life cycle. This life cycle helps tracking several aspects of the State including:
To understand the life cycle we need to get some insight on what is inside a ConanState. It is composed of.
- The Main Thread
- The Monitor Thread (for async operations)
- The Meta Flow (for introspection / error handling)
We also need to introduce the thread and flows
Threads and flows are the building blocks of ConanJs, while you don't need to have a deep understanding of them, it is helpful to have an overview.
Threads are streams of data that have the same shape.
Flows have statuses, each status then has, similar to the thread, a stream of data with the same shape.
A flow has a current status, and you can also transition to a different status.
The main thread is where all the data updates are stored.
Most of the features of the Conan State affect this Thread, it is also not accessible directly to protect it from unintentional changes.
The meta flow has the several statuses that are handy to provide with introspection.
Each ConanState allows easy access to the information encapsulated in the monitor flow and the meta flow through.... (can you guess it?).... more ConanState!
There are two properties in the ConanState for this
- asyncState. Returns a ConanState representation of the Monitor Info contained in the Monitor Thread. Since it returns a new ConanState, you can perform all the operations that you would with any other ConanState!
You could subscribe to the state produced by these properties as you would with any normal Conan State/ Conan Flow, this will work well if you want to consume in isolation the Meta info or the Monitor Info.
Many times though you are probably going to be interested in combining the data with either the Meta info and/or the Monitor info.
In that case you have two options.
Do this yourself by composing a new state using the original ConanState and the results from the properties asyncState/metaFlow, and subscribe to this new state.