我如何等待通过MergeHub
合并的单个源的完成和所有流的完成? MergeHub
返回Sink[T, NotUsed]
,迫不及待:
implicit val system: ActorSystem = ActorSystem("my-system")
implicit val mat: ActorMaterializer = ActorMaterializer()
implicit val ec: ExecutionContext = system.dispatcher
val src = Source.tick(1 second, 1 second, "message")
.zipWith(Source(1 to 15))((a, b) => s"$a-$b")
val printer = Sink.foreach[String](s => println(s))
val sink = MergeHub.source[String].to(printer).run()
val graph1: Future[Done] = src.runWith(printer) // Can be waited on
val graph2: NotUsed = src.runWith(sink) // Cannot be waited on apparently