Tutorial

12.1 The flow

             SetLines (self)          Back
               ┌────┐            ┌─────────────┐
               ▼    │            │             │
  start ──► Cart ───┴──SetAddress──► Address ──┘
             │                        │
             │ 2 hours idle            │ ChoosePayment
             ▼                        ▼
         Abandoned ──StartOver──► Cart   Payment ──PlaceOrder──► Placing

Each move is an event, sent by the customer. Each state holds a context, the data the checkout has gathered so far. An event can carry an input, check it with a guard, write part of it into the context, and move to a state. One that breaks a rule is refused with the reason, and the checkout stays where it was.

Placing is where the order is placed. In this chapter checkout stops there; the next chapter makes it run PlaceOrder.

SDK Reference

Machine | Rules | AddStateMachines | Machines over GraphQL | UsePersistedOperations | trax CLI


Next: 12.2 Where it lives