Skip to content

Instantly share code, notes, and snippets.

@nambrot
Created December 2, 2017 23:32
Show Gist options
  • Save nambrot/c9a5bf4f30ba2bc269eaec61ac880d90 to your computer and use it in GitHub Desktop.
Save nambrot/c9a5bf4f30ba2bc269eaec61ac880d90 to your computer and use it in GitHub Desktop.
implicit val system = ActorSystem("QuickStart")
implicit val materializer = ActorMaterializer()
def peekMatValue[T, M](src: Source[T, M]): (Source[T, M], Future[M]) = {
val p = Promise[M]
val s = src.mapMaterializedValue { m =>
p.trySuccess(m)
m
}
(s, p.future)
}
val (bloodPressureSource, bloodPressureQueueFuture) = peekMatValue(Source.queue[String](100, OverflowStrategy.dropHead))
val (heartRateSource, heartRateQueueFuture) = peekMatValue(Source.queue[String](100, OverflowStrategy.dropHead))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment