mergeAll
Merge multiple sources.
Signature
Source.mergeAll
Source.mergeAll
Flow.mergeAll
Flow.mergeAll
Description
Merge multiple sources. Picks elements randomly if all sources has elements ready.
Example
- Scala
-
source
val sourceA = Source(1 to 3) val sourceB = Source(4 to 6) val sourceC = Source(7 to 10) sourceA.mergeAll(List(sourceB, sourceC), eagerComplete = false).runForeach(println) // merging is not deterministic, can for example print 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Java
-
source
Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 3)); Source<Integer, NotUsed> sourceB = Source.from(Arrays.asList(4, 5, 6)); Source<Integer, NotUsed> sourceC = Source.from(Arrays.asList(7, 8, 9, 10)); sourceA .mergeAll(Arrays.asList(sourceB, sourceC), false) .runForeach(System.out::println, system); // merging is not deterministic, can for example print 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Reactive Streams semantics
emits when one of the inputs has an element available
backpressures when downstream backpressures
completes when all upstreams complete (This behavior is changeable to completing when any upstream completes by setting eagerComplete=true
.)