StreamChannel<T>.withCloseGuarantee constructor

StreamChannel<T>.withCloseGuarantee(Stream<T> stream, StreamSink<T> sink)

Creates a new StreamChannel that communicates over stream and sink.

This specifically enforces the second guarantee: closing the sink causes the stream to close before it emits any more events. This guarantee is invalidated when an asynchronous gap is added between the original stream's event dispatch and the returned stream's, for example by transforming it with a StreamTransformer. This is a lighter-weight way of preserving that guarantee in particular than StreamChannel.withGuarantees.

Implementation

factory StreamChannel.withCloseGuarantee(
        Stream<T> stream, StreamSink<T> sink) =>
    new CloseGuaranteeChannel(stream, sink);