Skip to content

Commit 713b5ac

Browse files
fgmacedoclaude
andcommitted
docs(quickstart): move is_terminated to parallel section with motivation
Instead of showing is_terminated as a bare syntax check after a flat example (where it adds no value), introduce it in the parallel states section where its purpose is clear: with compound and parallel states, completion depends on the structure, not a single final state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a3d30a1 commit 713b5ac

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

docs/quickstart.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ True
5353
>>> order.picked_up.is_active
5454
True
5555

56-
>>> order.is_terminated
57-
True
58-
5956
```
6057

6158
You can also call events as methods — `order.start()` is equivalent to
@@ -486,16 +483,30 @@ True
486483
>>> "drink_done" in order.configuration_values and "heating" in order.configuration_values
487484
True
488485

486+
>>> order.is_terminated # drink region finished, but snack hasn't
487+
False
488+
489489
>>> order.send("heat") # both done — auto-transitions to picked_up
490490
>>> order.picked_up.is_active
491491
True
492492

493+
>>> order.is_terminated
494+
True
495+
493496
```
494497

495498
`State.Parallel` activates all child regions at once. Each region
496499
processes events independently. The machine only transitions out when
497500
**every** region reaches a final state.
498501

502+
In a flat state machine, checking whether you've reached a specific
503+
final state is enough. But with compound and parallel states, completion
504+
depends on the structure — all regions of a parallel must finish, nested
505+
compounds must reach their own final children, and so on. The
506+
`is_terminated` property handles this for you: it returns `True` only
507+
when the entire machine has completed its work, regardless of how deeply
508+
nested the structure is. Use it instead of checking individual states.
509+
499510

500511
### History states: remember where you left off
501512

0 commit comments

Comments
 (0)