dispatch method

  1. @override
Future<void> dispatch(
  1. BuildContext context,
  2. ScopeManager scope,
  3. EnsembleAction action,
  4. Future<void> proceed(),
)
override

Implementation

@override
Future<void> dispatch(BuildContext context, ScopeManager scope,
    EnsembleAction action, Future<void> Function() proceed) async {
  if (_closed) return;
  _pending++;
  try {
    if (action is DispatchEventAction && identical(_owner(scope), _target)) {
      // This is the outer caller's event. A child's success is only visible
      // here when the real parent explicitly forwards it.
      final event = action.event;
      events.add({
        'name': event.name,
        'data': scope.dataContext.eval(event.data),
        if (event.error != null) 'error': event.error,
      });
    } else {
      await runZoned(proceed, zoneValues: {_scopeKey: scope});
    }
  } catch (error, stack) {
    _recordError(error, stack);
    rethrow;
  } finally {
    _pending--;
    _notifyIdle();
  }
}