fromFuture
Send the single value of the Future
when it completes and there is demand.
Description
Send the single value of the Future
when it completes and there is demand. If the future fails the stream is failed with that exception.
emits the future completes
completes after the future has completed
Example
- Scala
-
source
import akka.actor.ActorSystem import akka.stream.ActorMaterializer import akka.stream.scaladsl._ import akka.{ Done, NotUsed } import scala.concurrent.Future implicit val system: ActorSystem = ActorSystem() implicit val materializer: ActorMaterializer = ActorMaterializer() val source: Source[Int, NotUsed] = Source.fromFuture(Future.successful(10)) val sink: Sink[Int, Future[Done]] = Sink.foreach((i: Int) => println(i)) val done: Future[Done] = source.runWith(sink) //10