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