Created
July 15, 2018 20:01
-
-
Save ticofab/3d43f1c98aac65a40ca9227db9368e29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val bcMappingFlow = Flow.fromGraph(GraphDSL.create() { implicit b => | |
import GraphDSL.Implicits._ | |
val bc = b.add(Broadcast[Int](2)) | |
val printSink = Sink.foreach(println) | |
bc.out(1).map(i => i * 2) ~> printSink | |
FlowShape(bc.in, bc.out(0)) | |
}) | |
Source(1 to 10) | |
.via(bcMappingFlow) | |
.runForeach(n => println("runForeach, received: " + n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment