prependLazy

Prepends the given source to the flow, consuming it until completion before the original source is consumed.

Fan-in operators

Signature

Source.prependSource.prepend Flow.prependFlow.prepend

Description

Prepends the given source to the flow, consuming it until completion before the original source is consumed.

Both streams will be materialized together, however, the original stream will be pulled for the first time only after the prepended upstream was completed. (In contrast, @ref(prepend)[prepend.md], introduces single-element buffers after both, original and given sources so that the original source is also pulled once immediately.)

If materialized values needs to be collected prependLazyMat is available.

See also prepend which is detached.

Example

Scala
sourceval ladies = Source(List("Emma", "Emily"))
val gentlemen = Source(List("Liam", "William"))

gentlemen.prependLazy(ladies).runWith(Sink.foreach(println))
// this will print "Emma", "Emily", "Liam", "William"
Java
sourceimport akka.stream.javadsl.Keep;
import akka.stream.javadsl.Source;
import akka.stream.javadsl.Sink;

import java.util.*;

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

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.