Sink.cancelled

Immediately cancel the stream

Sink operators

Signature

Sink.cancelledSink.cancelled

Description

Immediately cancel the stream

Example

In this example, we have a source that generates numbers from 1 to 5 but as we have used cancelled we get NotUsed as materialized value and stream cancels.

Scala
sourceval source = Source(1 to 5)
source.runWith(Sink.cancelled)
Java
sourceSource<Integer, NotUsed> source = Source.range(1, 5);
NotUsed sum = source.runWith(Sink.cancelled(), system);
return sum;

Reactive Streams semantics

cancels immediately

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.