Sink.head
Materializes into a Future
which completes with the first value arriving, after this the stream is canceled.
Signature
Description
Materializes into a Future
which completes with the first value arriving, after this the stream is canceled. If no element is emitted, the Future
is failed.
Example
- Scala
-
source
val source = Source(1 to 10) val result: Future[Int] = source.runWith(Sink.head) result.map(println) // 1
- Java
Reactive Streams semantics
cancels after receiving one element
backpressures never