View on GitHub

guides

Finite State Machines

Background

https://en.wikipedia.org/wiki/Finite-state_machine

We utilize them to keep state of the application consistent and deterministic.

By limiting what actions do and when we prevent side effects of asynchronous actions being completed at unexpected times.

They also simplify complex step-by-step or multi-variable logic by dividing it into small independent pieces orchestrated by other small independent pieces.

For complex flows - use FSM that uses state of other FSMs - to keep complex flows simple.

Same principles apply to UI components behavior orchestration, just on a micro UI level.

Architecture

Typical use cases:

Usual leaf FSM graph

Usual non-leaf FSM graph

Usual orchestrating app logic top-level graph: