Glossary State Machine
State Machine
Also known as:
finite state machine, fsm, statechart, statechartsEngineeringModeling
Definition
A model of behavior as a finite set of states, where the system is in exactly one state at a time and events trigger transitions between them
It makes impossible states unrepresentable. A request is idle, loading, success or error, never loading and error at once. David Harel's statecharts (1987) added nesting and parallel states. XState implements them in JavaScript, and UML's state machine diagram draws them.
Drawn as a UML state diagram, or as a Mermaid stateDiagram (see the
Mermaid guide).
The request example above, as a diagram:
stateDiagram-v2
[*] --> idle
idle --> loading: fetch
loading --> success: resolved
loading --> error: rejected
error --> loading: retry
success --> loading: refetch
success --> [*]
Every arrow is an allowed transition; anything not drawn cannot happen. That is the point: "loading and error at once" has no state to be in.