take
Pass n
incoming elements downstream and then complete
Simple operators
Signature
Source.take
Source.take
Flow.take
Flow.take
Description
Pass n
incoming elements downstream and then complete
Example
- Scala
-
sourceSource(1 to 5).take(3).runForeach(println)
// 1
// 2
// 3
- Java
-
sourceSource.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
Found an error in this documentation? The source code for this page can be found
here.
Please feel free to edit and contribute a pull request.