onEnterFromChannel<P> method

  1. @override
void onEnterFromChannel<P>(
  1. Channel<P> channel,
  2. void build(
    1. TransitionHandlerBuilder<D, P>
    )
)
override

Describes how transition to this state through channel should be handled.

The build function is called with a TransitionHandlerBuilder that can be used to describe the behavior of the entry transition.

Implementation

@override
void onEnterFromChannel<P>(
  Channel<P> channel,
  void Function(TransitionHandlerBuilder<D, P>) build,
) {
  var builder = TransitionHandlerBuilder<D, P>._(
    key,
    _log,
    (transCtx) {
      try {
        return transCtx.payloadOrThrow<P>();
      } catch (e) {
        throw StateError('Failed to enter channel '
            '${channel.label != null ? '"${channel.label}" ' : ''}'
            'to state ${channel.to}: $e');
      }
    },
  );
  build(builder);
  _onEnter = builder._descriptor;
}