Sink.combine

Combine several sinks into one using a user specified strategy

Sink operators

Signature

Sink.combineSink.combine

Description

Combine several sinks into one using a user specified strategy

Example

This example shows how to combine multiple sinks with a Fan-out Junction.

Scala
sourceval sendRemotely = Sink.actorRef(actorRef, "Done", _ => "Failed")
val localProcessing = Sink.foreach[Int](_ => /* do something useful */ ())

val sink = Sink.combine(sendRemotely, localProcessing)(Broadcast[Int](_))

Source(List(0, 1, 2)).runWith(sink)
Java
sourceSink<Integer, NotUsed> sendRemotely = Sink.actorRef(actorRef, "Done");
Sink<Integer, CompletionStage<Done>> localProcessing =
    Sink.<Integer>foreach(
        a -> {
          /*do something useful*/
        });
Sink<Integer, NotUsed> sinks =
    Sink.combine(sendRemotely, localProcessing, new ArrayList<>(), a -> Broadcast.create(a));

Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, system);

Reactive Streams semantics

cancels depends on the strategy

backpressures depends on the strategy

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.