@@ -25,10 +25,41 @@ triggers the change, and *what happens* as a result.
2525
2626```
2727
28- Even in this minimal example, all five core concepts appear:
28+ Even in this minimal example, the core concepts appear:
29+
30+ | Concept | What it is | Declared as |
31+ | ---| ---| ---|
32+ | {ref}` StateChart <statechart> ` | The container and runtime for the machine | ` class MyChart(StateChart) ` |
33+ | {ref}` State <states> ` | A mode or condition of the system | ` State() ` , ` State.Compound ` , ` State.Parallel ` |
34+ | {ref}` Transition <transitions> ` | A link from source state to target state | ` source.to(target) ` , ` target.from_(source) ` |
35+ | {ref}` Event <events> ` | A signal that triggers transitions | Class-level assignment or ` Event(...) ` |
36+ | {ref}` Action <actions> ` | A side-effect during state changes | ` on ` , ` before ` , ` after ` , ` enter ` , ` exit ` callbacks |
37+ | {ref}` Condition <conditions> ` | A guard that allows/blocks a transition | ` cond ` , ` unless ` , ` validators ` parameters |
38+ | {ref}` Listener <listeners> ` | An external observer of the lifecycle | ` listeners = [...] ` class attribute |
39+
40+
41+ (concepts-statechart)=
42+
43+ ## StateChart
44+
45+ A {ref}` StateChart <statechart> ` is the container for states, transitions,
46+ and events. It defines the topology (which states exist and how they
47+ connect) and provides the runtime API — sending events, querying the
48+ current configuration, and managing listeners.
49+
50+ In the turnstile example, ` Turnstile ` is the ` StateChart ` . After
51+ instantiation, ` sm ` holds the runtime state and exposes methods like
52+ ` sm.send("coin") ` , ` sm.configuration ` , and ` sm.allowed_events ` .
53+
54+ ``` {seealso}
55+ See [](statechart.md) for the full reference: creating instances, sending
56+ events, querying configuration, checking termination, and managing
57+ listeners at runtime.
58+ ```
2959
3060
3161(concepts-states)=
62+
3263## States
3364
3465A ** state** describes what the system is doing right now. At any point in
@@ -46,12 +77,13 @@ See [](states.md) for the full reference: initial and final states, compound
4677
4778
4879(concepts-transitions)=
80+
4981## Transitions
5082
5183A ** transition** is a link between a ** source** state and a ** target** state.
5284When a transition fires, the system leaves the source and enters the target.
53- Transitions can carry {ref}` actions ` (side-effects) and
54- {ref}` conditions <validators and guards > ` (guards that must be satisfied).
85+ Transitions can carry {ref}` actions <actions> ` (side-effects) and
86+ {ref}` conditions <conditions > ` (guards that must be satisfied).
5587
5688In the turnstile, ` locked.to(unlocked) ` is a transition: it moves the system
5789from ` locked ` to ` unlocked ` and runs the ` thank_you ` action along the way.
@@ -64,6 +96,7 @@ and more.
6496
6597
6698(concepts-events)=
99+
67100## Events
68101
69102An ** event** is a signal that something has happened. Events trigger
@@ -83,6 +116,7 @@ microsteps work under the hood.
83116
84117
85118(concepts-actions)=
119+
86120## Actions
87121
88122An ** action** is a side-effect that runs during a transition or on
@@ -100,7 +134,8 @@ execution order, dependency injection, and all available hooks.
100134
101135
102136(concepts-conditions)=
103- ## Conditions and validators
137+
138+ ## Conditions
104139
105140A ** condition** (also called a ** guard** ) is a predicate that must evaluate
106141to ` True ` for a transition to fire. A ** validator** is similar but raises an
@@ -111,16 +146,21 @@ different guard — the first one that passes wins.
111146
112147``` {seealso}
113148See [](guards.md) for the full reference: `cond`, `unless`, `validators`,
114- boolean expressions, and the `In()` condition .
149+ boolean expressions, and checking enabled events .
115150```
116151
117152
118- ## Quick reference
153+ (concepts-listeners)=
119154
120- | Concept | What it is | Declared as |
121- | ---------------| -----------------------------------------| -----------------------------------|
122- | ** State** | A mode or condition of the system | ` State() ` , ` State.Compound ` , ` State.Parallel ` |
123- | ** Transition** | A link from source state to target state| ` source.to(target) ` , ` target.from_(source) ` |
124- | ** Event** | A signal that triggers transitions | Class-level assignment or ` Event(...) ` |
125- | ** Action** | A side-effect during state changes | Callbacks: ` on ` , ` before ` , ` after ` , ` enter ` , ` exit ` |
126- | ** Condition** | A guard that allows/blocks a transition | ` cond ` , ` unless ` , ` validators ` parameters |
155+ ## Listeners
156+
157+ A {ref}` listener <listeners> ` is an external object that observes a state
158+ machine's lifecycle without modifying its class. Listeners receive the same
159+ callbacks as the state machine itself — ` on_enter_state() ` ,
160+ ` after_transition() ` , and so on — enabling cross-cutting concerns like
161+ logging, persistence, or telemetry to be attached and removed independently.
162+
163+ ``` {seealso}
164+ See [](listeners.md) for the full reference: defining listeners, class-level
165+ declarations, runtime attachment, the `setup()` protocol, and inheritance.
166+ ```
0 commit comments