wait method

FutureOr<Iterable<T>> wait({
  1. _TOnErrorCallback? onError,
  2. bool eagerError = true,
})

Executes all queued operations and returns their results.

This triggers the invocation of all pending functions. It returns a FutureOr<Iterable<T>> that completes with the results.

  • onError: A specific error handler for this call, which runs in addition to the waiter's default error handler.
  • eagerError: If true (the default), fails as soon as one operation fails, similar to Future.wait — but secondary rejections are absorbed rather than being leaked to the surrounding Zone (a deliberate divergence from Future.wait for audit-trail cleanliness).

Both the ctor-level handler and the call-level handler are awaited if they return a Future, and a throw inside one never prevents the other from running — handler failures are surfaced through Zone.current.handleUncaughtError instead, preserving the original incident as the caller-facing error.

Implementation

FutureOr<Iterable<T>> wait({
  _TOnErrorCallback? onError,
  bool eagerError = true,
}) {
  final ctorHandler = _onError;
  final callHandler = onError;
  final factories = _operations.map((op) => op.run);
  if (ctorHandler == null && callHandler == null) {
    return waitAlikeF(factories, eagerError: eagerError);
  }
  return waitAlikeF(
    factories,
    onError: (Object e, StackTrace? s) =>
        _runHandlers(ctorHandler, callHandler, e, s),
    eagerError: eagerError,
  );
}