State Machine Builder
DSL builder for creating state machines with a fluent API.
This builder provides a declarative way to define state machines similar to the coroutine-based guide but adapted for zero dependencies. It supports event handling, state transitions, guards, and side effects.
Parameters
The type of states in the state machine
The type of events in the state machine
Properties
The initial state of the state machine. Must be set before building.
Starts the initial state configuration with "starting at State" syntax.
Optional validator for state validation.
Starts observer configuration with "watching" keyword.
Functions
Configures a state with conversational syntax: "during State { ... }"
Alternative syntax for setting initial state: "initially State"
Adds a global side effect that runs on every transition.
Adds a side effect that runs on every state transition.
Sets the state validator directly.
Sets the state validator with conversational syntax.