zip
Combines elements from each of multiple sources into tuples and passes the tuples downstream.
Signature
Description
Combines elements from each of multiple sources into tuples and passes the tuples downstream.
See also:
Examples
- Scala
-
source
import akka.stream.scaladsl.Source import akka.stream.scaladsl.Sink val sourceFruits = Source(List("apple", "orange", "banana")) val sourceFirstLetters = Source(List("A", "O", "B")) sourceFruits.zip(sourceFirstLetters).runWith(Sink.foreach(println)) // this will print ('apple', 'A'), ('orange', 'O'), ('banana', 'B')
- Java
Reactive Streams semantics
emits when both of the inputs have an element available
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 either upstream completes