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 : @@snip StreamPartialGraphDSLDocSpec.scala {#sink-combine }

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.