take
Pass n
incoming elements downstream and then complete
Signature
Source.take
Source.take
Flow.take
Flow.take
Description
Pass n
incoming elements downstream and then complete
Example
- Scala
-
source
Source(1 to 5).take(3).runForeach(println) // 1 // 2 // 3
- Java
-
source
Source.from(Arrays.asList(1, 2, 3, 4, 5)).take(3).runForeach(System.out::println, system); // this will print: // 1 // 2 // 3
Reactive Streams semantics
emits while the specified number of elements to take has not yet been reached
backpressures when downstream backpressures
completes when the defined number of elements has been taken or upstream completes
1.1.2+29-e21fa9eb*