dispatch method
The single entry point. Returns the transition and applies it to the internal state.
Implementation
HintTransition dispatch(
HintEvent event, {
bool Function(String targetId)? targetPresent,
}) {
final current = _state;
// One tour at a time. In debug this is a loud contract; in release a no-op.
if (event is HintStart && !current.isIdle) {
assert(
false,
"hintful: tour '${event.tour.id}' started while $current is active"
' — one tour at a time',
);
return HintTransition(state: current, effects: const <HintEffect>[]);
}
final effects = <HintEffect>[];
final next = switch (current) {
HintIdle() => _reduceIdle(event, effects),
HintWaiting(:final tour, :final stepIndex) =>
_reduceWaiting(tour, stepIndex, event, effects, targetPresent),
HintActive(:final tour, :final stepIndex) =>
_reduceActive(tour, stepIndex, event, effects, targetPresent),
};
_state = next;
return HintTransition(
state: next,
effects: List<HintEffect>.unmodifiable(effects),
);
}