combine

Combine several sources, using a given strategy such as merge or concat, into one source.

Source operators

Signature

def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(strategy: Int => Graph[UniformFanInShape[T, U], NotUsed]): Source[U, NotUsed]
def combine[T, U](first: Source[T, _], second: Source[T, _], rest: Source[T, _]*)(strategy: Int => Graph[UniformFanInShape[T, U], NotUsed]): Source[U, NotUsed]
def combineMat[T, U, M1, M2, M](first: Source[T, M1], second: Source[T, M2])(strategy: Int => Graph[UniformFanInShape[T, U], NotUsed])(matF: (M1, M2) => M): Source[U, M]

Description

emits when there is demand, but depending on the strategy

completes when all sources has completed

Examples

Scala
sourceimport akka.stream._

val sources = immutable.Seq(Source(List(1, 2, 3)), Source(List(10, 20, 30)))

Source
  .combine(sources(0), sources(1))(Concat(_))
  .runWith(Sink.seq)
  // This will produce the Seq(1, 2, 3, 10, 20, 30)
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.