prepend
Prepends the given source to the flow, consuming it until completion before the original source is consumed.
Signature
def prepend[U >: Out, Mat2](that: Graph[SourceShape[U], Mat2]): Repr[U]
def prependMat[U >: Out, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) => Mat3): ReprMat[U, Mat3]
Description
Prepends the given source to the flow, consuming it until completion before the original source is consumed.
If materialized values needs to be collected prependMat
is available.
emits when the given stream has an element available; if the given input completes, it tries the current one
backpressures when downstream backpressures
completes when all upstreams complete
Example
- Scala
-
source
import akka.stream.scaladsl.Source import akka.stream.scaladsl.Sink val ladies = Source(List("Emma", "Emily")) val gentlemen = Source(List("Liam", "William")) gentlemen.prepend(ladies).runWith(Sink.foreach(println)) // this will print "Emma", "Emily", "Liam", "William"
- Java
-
source
import akka.stream.javadsl.Source; import akka.stream.javadsl.Sink; import java.util.Arrays; Source<String, NotUsed> ladies = Source.from(Arrays.asList("Emma", "Emily")); Source<String, NotUsed> gentlemen = Source.from(Arrays.asList("Liam", "William")); gentlemen.prepend(ladies).runWith(Sink.foreach(System.out::print), materializer); // this will print "Emma", "Emily", "Liam", "William"