PersistentFsmTransition
Defined in: src/fsm/PersistentFSM.ts:93
One entry in the transition table.
Type Parameters
Section titled “Type Parameters”SName extends string
Cmd
Event
Data
Properties
Section titled “Properties”
readonlyevent:Event|Event[] | ((cmd,data) =>Event|Event[])
Defined in: src/fsm/PersistentFSM.ts:115
Event(s) to persist when this transition fires. Three shapes:
- Literal —
{ kind: 'paid' }: a single event persisted atomically as one journal entry. - Array —
[evtA, evtB]: multiple events persisted in onepersistAllcall (#66) so they share a logical transaction;applyEventruns once per event and the post-apply final state is checked againstnext. An empty array is treated as a no-op transition (no events persisted, no state change) — use aguardinstead if “skip on this condition” is the actual intent. - Function —
(cmd, data) => Event | Event[]: lazily evaluated when the transition fires; otherwise behaves exactly like the literal / array forms above.
guard?
Section titled “guard?”
readonlyoptionalguard?: (cmd,data) =>boolean
Defined in: src/fsm/PersistentFSM.ts:133
Optional pre-check — if it returns false, the transition
is skipped (no event persisted, no state change). Use for
conditional dispatch like “pay only if amount > 0”. Logged
at debug.
Parameters
Section titled “Parameters”Cmd
Data
Returns
Section titled “Returns”boolean
readonlynext:SName
Defined in: src/fsm/PersistentFSM.ts:126
State name the FSM moves to after every event applies. When
event is an array, only the final post-replay state is
compared against next — intermediate transitions inside the
array don’t have to match. Mainly informational; applyEvent
is what actually drives the transition.