stream method

  1. @override
Stream<RunOutput> stream(
  1. RunInput input, {
  2. RunnableOptions? options,
})
override

Streams the output of invoking the Runnable on the given input.

  • input - the input to invoke the Runnable on.
  • options - the options to use when invoking the Runnable.

Implementation

@override
Stream<RunOutput> stream(
  RunInput input, {
  RunnableOptions? options,
}) async* {
  Object? firstError;
  for (final runnable in [mainRunnable, ...fallbacks]) {
    try {
      final stream = runnable.stream(
        input,
        options: firstError == null
            ? options
            : runnable.getCompatibleOptions(options),
      );
      await for (final output in stream) {
        yield output;
      }
      return;
    } catch (e) {
      firstError ??= e;
    }
  }
  throw Exception('All runnables failed. First error: $firstError');
}