States store outgoing transitions as callbacks keyed by target state. The state object itself does not contain behavior beyond transition bookkeeping, which keeps it lightweight and easy to compose.
Transitions are usually configured with the [] operator:
var a = new State();
var b = new State();
a[b] = () -> trace("a -> b");Static methods
staticaddTransition(this:StateData, to:State, ?transition:() ‑> Void):Void
Adds or replaces a transition to another state.
When transition is omitted, an empty callback is stored so the transition
is still considered valid.
Parameters:
to | Target state. |
|---|---|
transition | Callback invoked when the transition is taken. |
staticgetTransition(this:StateData, to:State):Null<Null<() ‑> Void>>
Gets the transition callback for a target state.
Parameters:
to | Target state. |
|---|
Returns:
The transition callback or null.
statichasTransition(this:StateData, to:State):Bool
Checks whether a transition to a target state exists.
Parameters:
to | Target state. |
|---|
Returns:
true if a transition is defined.
staticremoveTransition(this:StateData, to:State):Void
Removes a transition to a target state.
Parameters:
to | Target state. |
|---|