concat

After completion of the original upstream the elements of the given source will be emitted.

Fan-in operators

Signature

def concat[U >: Out, Mat2](that: Graph[SourceShape[U], Mat2]): Repr[U]
def concatMat[U >: Out, Mat2, Mat3](that: Graph[SourceShape[U], Mat2])(matF: (Mat, Mat2) ⇒ Mat3): ReprMat[U, Mat3]

Description

After completion of the original upstream the elements of the given source will be emitted.

emits when the current stream has an element available; if the current input completes, it tries the next one

backpressures when downstream backpressures

completes when all upstreams complete

Example

Scala
import akka.stream.scaladsl.Source
import akka.stream.scaladsl.Sink

val sourceA = Source(List(1, 2, 3, 4))
val sourceB = Source(List(10, 20, 30, 40))

sourceA.concat(sourceB).runWith(Sink.foreach(println))
//prints 1, 2, 3, 4, 10, 20, 30, 40
Java
import akka.stream.javadsl.Source;
import akka.stream.javadsl.Sink;
import java.util.Arrays;

Source<Integer, NotUsed> sourceA = Source.from(Arrays.asList(1, 2, 3, 4));
Source<Integer, NotUsed> sourceB = Source.from(Arrays.asList(10, 20, 30, 40));
sourceA.concat(sourceB).runWith(Sink.foreach(System.out::print), materializer);
//prints 1, 2, 3, 4, 10, 20, 30, 40
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.