pipe<NewRunOutput extends Object?, NewCallOptions extends RunnableOptions> method

  1. @override
RunnableSequence<RunInput, NewRunOutput> pipe<NewRunOutput extends Object?, NewCallOptions extends RunnableOptions>(
  1. Runnable<RunOutput, NewCallOptions, NewRunOutput> next
)
override

Pipes the output of this RunnableSequence into another Runnable.

  • next - the Runnable to pipe the output into.

Implementation

@override
RunnableSequence<RunInput, NewRunOutput> pipe<NewRunOutput extends Object?,
    NewCallOptions extends RunnableOptions>(
  final Runnable<RunOutput, NewCallOptions, NewRunOutput> next,
) {
  if (next is RunnableSequence<RunOutput, NewRunOutput>) {
    final nextSeq = next as RunnableSequence<RunOutput, NewRunOutput>;
    return RunnableSequence(
      first: first,
      middle: [...middle, last, nextSeq.first, ...nextSeq.middle],
      last: nextSeq.last,
    );
  } else {
    return RunnableSequence(
      first: first,
      middle: [...middle, last],
      last: next,
    );
  }
}