prepend
Prepends the given source to the flow, consuming it until completion before the original source is consumed.
Signature
Source.prepend
Source.prepend
Flow.prepend
Flow.prepend
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.
Example
- Scala
-
source
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.Keep; import akka.stream.javadsl.Source; import akka.stream.javadsl.Sink; import java.util.*; 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), system); // this will print "Emma", "Emily", "Liam", "William"
Reactive Streams semantics
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