zipAll

Combines elements from two sources into tuples Pair handling early completion of either source.

Fan-in operators

Signature

Source.zipAllSource.zipAll Flow.zipAllFlow.zipAll

Description

Combines elements from two sources into tuples Pair and passes downstream. If either source completes, a default value is combined with each value from the other source until it completes.

See also:

Example

Scala
sourceval numbers = Source(1 :: 2 :: 3 :: 4 :: Nil)
val letters = Source("a" :: "b" :: "c" :: Nil)

numbers.zipAll(letters, -1, "default").runForeach(println)
// prints:
// (1,a)
// (2,b)
// (3,c)
// (4,default)
Java
source
Source<Integer, NotUsed> numbers = Source.from(Arrays.asList(1, 2, 3, 4)); Source<String, NotUsed> letters = Source.from(Arrays.asList("a", "b", "c")); numbers.zipAll(letters, -1, "default").runForeach(System.out::println, system); // prints: // Pair(1,a) // Pair(2,b) // Pair(3,c) // Pair(4,default)

Reactive Streams semantics

emits at first emits when both inputs emit, and then as long as any input emits (coupled to the default value of the completed input)

backpressures both upstreams when downstream backpressures but also on an upstream that has emitted an element until the other upstream has emitted an element

completes when both 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.