drop
Drop n
elements and then pass any subsequent element downstream.
Signature
Source.drop
Source.drop
Flow.drop
Flow.drop
Description
Drop n
elements and then pass any subsequent element downstream.
Example
Given a Source
of numbers we can drop the first 3 elements with the drop
operator:
- Scala
-
source
val fiveInts: Source[Int, NotUsed] = Source(1 to 5) val droppedThreeInts: Source[Int, NotUsed] = fiveInts.drop(3) droppedThreeInts.runForeach(println) // 4 // 5
- Java
-
source
Source<Integer, NotUsed> fiveIntegers = Source.from(Arrays.asList(1, 2, 3, 4, 5)); Source<Integer, NotUsed> droppedThreeInts = fiveIntegers.drop(3); droppedThreeInts.runForeach(System.out::println, system); // 4 // 5
Reactive Streams semantics
emits when the specified number of elements has been dropped already
backpressures when the specified number of elements has been dropped and downstream backpressures
completes when upstream completes
1.1.2