onStreamDone<T> method

SelectBuilder<R> onStreamDone<T>(
  1. Stream<T> stream,
  2. FutureOr<R> body(), {
  3. Object? tag,
  4. bool if_()?,
})

Race a Stream - waits for completion (done event).

Triggers when the stream completes normally or with an error. Use this to react to stream lifecycle events.

Example:

await XSelect.run<String>((s) => s
  ..onStream(dataStream, (data) => 'Data: $data')
  ..onStreamDone(dataStream, () => 'Stream completed')
  ..onTimeout(Duration(minutes: 5), () => 'Stream timeout')
);

See also:

Implementation

SelectBuilder<R> onStreamDone<T>(
    Stream<T> stream, FutureOr<R> Function() body,
    {Object? tag, bool Function()? if_}) {
  return onFuture<void>(stream.drain(), (_) => body(), tag: tag, if_: if_);
}