send<E extends AutomataEvent> method
void
send<E extends AutomataEvent>(
- E event
Send an event to the state machine.
The currently active StateNodeDefinition
will pick up this event and
execute any TransitionDefinition
that matches it's GuardCondition.
For every executed transitions, the provided OnTransitionCallback is called.
In order to support "eventless transitions" a NullEvent is sent when a transition is performed.
Implementation
void send<E extends AutomataEvent>(E event) {
final nodes = value.activeNodes;
final transitions = <TransitionDefinition>{};
for (final node in nodes) {
transitions.addAll(node.getTransitions(event));
}
if (transitions.isEmpty) {
return;
}
for (final transition in transitions) {
value = transition.trigger(value, event);
onTransition?.call(event, value);
_controller.add(value);
}
if (E != NullEvent) {
send(const NullEvent());
}
}