onFork<E extends Event> method

void onFork<E extends Event>(
  1. BuildFork<E> buildFork, {
  2. GuardCondition<E> condition = noopGuardCondition,
  3. SideEffect<E>? sideEffect,
  4. String? conditionLabel,
  5. String? sideEffectLabel,
})

Used to enter a co-region by targeting the set of states within the coregion to transition to.

Implementation

void onFork<E extends Event>(BuildFork<E> buildFork,
    {GuardCondition<E> condition = noopGuardCondition,
    SideEffect<E>? sideEffect,
    String? conditionLabel,
    String? sideEffectLabel}) {
  final builder = ForkBuilder<E>();
  buildFork(builder);
  final definition = builder.build();

  final choice = ForkTransitionDefinition<S, E>(
      _stateDefinition, definition, condition, sideEffect,
      sideEffectLabel: sideEffectLabel, conditionLabel: conditionLabel);

  _stateDefinition.addTransition(choice);
}