This documentation regards version 2.10.4+3-f7095f01-SNAPSHOT, however the current version is 2.10.4.
Sink.last
Materializes into a CompletionStage
which will complete with the last value emitted when the stream completes.
Signature
Description
Materializes into a CompletionStage
which will complete with the last value emitted when the stream completes. If the stream completes with no elements the CompletionStage
is failed.
Example
- Scala
- Java
-
source
Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); CompletionStage<Integer> result = source.runWith(Sink.last(), system); result.thenAccept(System.out::println); // 10
Reactive Streams semantics
cancels never
backpressures never