dropRepeated
Only pass on those elements that are distinct from the previous element.
Signature
Source.dropRepeatedSource.dropRepeated Flow.dropRepeatedFlow.dropRepeated
Description
Only pass on those elements that are distinct from the previous element.
Example
For example, given a Source of numbers, we just want to pass distinct numbers downstream:
- Scala
-
source
Source(List(1, 2, 2, 3, 3, 1, 4)) .dropRepeated() .runForeach(println) // prints: // 1 // 2 // 3 // 1 // 4 - Java
-
source
Source.from(Arrays.asList(1, 2, 2, 3, 3, 1, 4)) .dropRepeated() .runForeach(System.out::println, system); // prints: // 1 // 2 // 3 // 1 // 4
Reactive Streams semantics
emits when the element is distinct from the previous element
backpressures when the element is distinct from the previous element and downstream backpressures
completes when upstream completes
API docs
1.2.1