Created
September 13, 2016 09:41
-
-
Save dakatsuka/ae8f55de6804dc4d219ff6e87363f51d 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
implicit val system = ActorSystem() | |
implicit val executor = system.dispatcher | |
implicit val materializer = ActorMaterializer() | |
val source: Source[Int, NotUsed] = Source(1 to 10) | |
val flow1: Flow[Int, Int, NotUsed] = Flow[Int].map(_ * 10) | |
val flow2: Flow[Int, Int, NotUsed] = Flow[Int].filter(_ % 3 == 0) | |
val flow3: Flow[Int, Int, NotUsed] = Flow[Int].statefulMapConcat { () => | |
var sequence = 0 | |
i => | |
sequence = sequence + i | |
List(sequence) | |
} | |
source.via(flow1).via(flow2).via(flow3).runForeach(println) | |
// 30 | |
// 90 | |
// 180 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment