Add method foreachAsync to Sink object
This commit is contained in:
parent
ed951ccede
commit
a679f6f59e
7 changed files with 374 additions and 0 deletions
24
akka-docs/src/test/scala/docs/stream/SinkRecipeDocSpec.scala
Normal file
24
akka-docs/src/test/scala/docs/stream/SinkRecipeDocSpec.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package docs.stream
|
||||
|
||||
import akka.stream.scaladsl.{ Sink, Source }
|
||||
import docs.stream.cookbook.RecipeSpec
|
||||
|
||||
import scala.concurrent.Future
|
||||
|
||||
class SinkRecipeDocSpec extends RecipeSpec {
|
||||
"Sink.foreachAsync" must {
|
||||
"processing each element asynchronously" in {
|
||||
def asyncProcessing(value: Int): Future[Unit] = Future { println(value) }(system.dispatcher)
|
||||
//#forseachAsync-processing
|
||||
//def asyncProcessing(value: Int): Future[Unit] = _
|
||||
|
||||
Source(1 to 100)
|
||||
.runWith(Sink.foreachAsync(10)(asyncProcessing))
|
||||
//#forseachAsync-processing
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue