durian-hypermediaStyle

All fixtures · From the Format page · format/90-state-diagram.dh.md

Source
---
title: "State: a state machine that its steps walk"
description: A state diagram drawn from its transitions; each step walks one transition (SPEC 3.2 State). Shown live, then static.
---

## State: a state machine that its steps walk

A `state` part draws a state machine from its transitions. `at` says where the walk is, and `fire` takes the one transition with that event from there.

```state title="An order"
[start] -> cart
cart -> paying "check out"
paying -> paid "card accepted"
paying -> cart "card declined"
paid -> shipped "ship"
shipped -> [end]
state paying "Paying" note="waits up to 10 minutes for the bank"
group done "Fulfilment": paid, shipped
@step A shopper fills the cart.
at cart
@step They check out.
fire check out
@step The bank declines the card: back to the cart.
fire card declined
@step They try another card, and the bank takes it.
at paying
fire card accepted
```


The same machine, static (the finished walk, no player):

```state static=true title="An order, static"
[start] -> cart
cart -> paying "check out"
paying -> paid "card accepted"
paying -> cart "card declined"
paid -> shipped "ship"
shipped -> [end]
state paying "Paying" note="waits up to 10 minutes for the bank"
group done "Fulfilment": paid, shipped
@step A shopper fills the cart.
at cart
@step They check out.
fire check out
@step The bank declines the card: back to the cart.
fire card declined
@step They try another card, and the bank takes it.
at paying
fire card accepted
```
LLM view
---
title: "State: a state machine that its steps walk"
description: A state diagram drawn from its transitions; each step walks one transition (SPEC 3.2 State). Shown live, then static.
source: format/90-state-diagram.dh.md
---
<!-- Made by dh llm from the source; nobody edits this file. -->

## State: a state machine that its steps walk

A `state` part draws a state machine from its transitions. `at` says where the walk is, and `fire` takes the one transition with that event from there.

State machine: An order. Starts at cart; ends after shipped.

| from | on | to |
| --- | --- | --- |
| cart | check out | paying |
| paying | card accepted | paid |
| paying | card declined | cart |
| paid | ship | shipped |

- paying (Paying): waits up to 10 minutes for the bank
- done (Fulfilment), a group of paid, shipped; a transition to it enters paid

1. A shopper fills the cart.
   at cart
2. They check out.
   cart -> paying (check out)
3. The bank declines the card: back to the cart.
   paying -> cart (card declined)
4. They try another card, and the bank takes it.
   at paying
   paying -> paid (card accepted)

The same machine, static (the finished walk, no player):

State machine: An order, static. Starts at cart; ends after shipped.

| from | on | to |
| --- | --- | --- |
| cart | check out | paying |
| paying | card accepted | paid |
| paying | card declined | cart |
| paid | ship | shipped |

- paying (Paying): waits up to 10 minutes for the bank
- done (Fulfilment), a group of paid, shipped; a transition to it enters paid

1. A shopper fills the cart.
   at cart
2. They check out.
   cart -> paying (check out)
3. The bank declines the card: back to the cart.
   paying -> cart (card declined)
4. They try another card, and the bank takes it.
   at paying
   paying -> paid (card accepted)

State: a state machine that its steps walk

A state part draws a state machine from its transitions. at says where the walk is, and fire takes the one transition with that event from there.

State machine: An order. Starts at cart; ends after shipped. | from | on | to | | --- | --- | --- | | cart | check out | paying | | paying | card accepted | paid | | paying | card declined | cart | | paid | ship | shipped | - paying (Paying): waits up to 10 minutes for the bank - done (Fulfilment), a group of paid, shipped; a transition to it enters paid 1. A shopper fills the cart. at cart 2. They check out. cart -> paying (check out) 3. The bank declines the card: back to the cart. paying -> cart (card declined) 4. They try another card, and the bank takes it. at paying paying -> paid (card accepted)

An order
FulfilmentFulfilmentcheck outcard acceptedcard declinedshipstartcartcartPaying · waits up to 10 minutes for the bankPayingpaidpaidshippedshippedend
1A shopper fills the cart.
1 / 4
All steps (4)

The same machine, static (the finished walk, no player):

State machine: An order, static. Starts at cart; ends after shipped. | from | on | to | | --- | --- | --- | | cart | check out | paying | | paying | card accepted | paid | | paying | card declined | cart | | paid | ship | shipped | - paying (Paying): waits up to 10 minutes for the bank - done (Fulfilment), a group of paid, shipped; a transition to it enters paid 1. A shopper fills the cart. at cart 2. They check out. cart -> paying (check out) 3. The bank declines the card: back to the cart. paying -> cart (card declined) 4. They try another card, and the bank takes it. at paying paying -> paid (card accepted)

An order, static
FulfilmentFulfilmentcheck outcard acceptedcard declinedshipstartcartcartPaying · waits up to 10 minutes for the bankPayingpaidpaidshippedshippedendcard accepted

4 They try another card, and the bank takes it.

All steps (4)
  1. A shopper fills the cart.
  2. They check out.
  3. The bank declines the card: back to the cart.
  4. They try another card, and the bank takes it.