Sink.lastOption
Materialize a Future[Option[T]]
which completes with the last value emitted wrapped in an Some
when the stream completes.
Signature
Description
Materialize a Future[Option[T]]
which completes with the last value emitted wrapped in an Some
when the stream completes. if the stream completes with no elements the CompletionStage
is completed with None
.
Example
- Scala
-
source
val source = Source.empty[Int] val result: Future[Option[Int]] = source.runWith(Sink.lastOption) result.map(println) // None
- Java
Reactive Streams semantics
cancels never
backpressures never