zip
Combines elements from each of multiple sources into tuples and passes the tuples downstream.
Signature
def zip[U](that: Graph[SourceShape[U], _]): Repr[(Out, U)]
def zipMat[U, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) => Mat3): ReprMat[(Out, U), Mat3]
Description
Combines elements from each of multiple sources into tuples and passes the tuples downstream.
emits when all of the inputs have an element available
backpressures when downstream backpressures
completes when any upstream completes
Example
- 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