Issue 24519: Created method lazilyAsync for both DSLs and adds section in docs (#24568)

* Issue 24519: Created method lazilyAsync for both DSLs and adds section in docs.

* Issue 24519: Changes according to code review

* Issue 24519: Added unit tests

* Update LazilyAsyncSpec.scala

* Issue 24519: Added copyright
This commit is contained in:
Oleksii Tkachuk 2018-02-21 19:15:25 -06:00 committed by Konrad `ktoso` Malawski
parent 11b6065d97
commit 80da4cadee
4 changed files with 110 additions and 0 deletions

View file

@ -251,6 +251,16 @@ object Source {
def lazily[T, M](create: function.Creator[Source[T, M]]): Source[T, CompletionStage[M]] =
scaladsl.Source.lazily[T, M](() create.create().asScala).mapMaterializedValue(_.toJava).asJava
/**
* Creates a `Source` from supplied future factory that is not called until downstream demand. When source gets
* materialized the materialized future is completed with the value from the factory. If downstream cancels or fails
* without any demand the create factory is never called and the materialized `Future` is failed.
*
* @see [[Source.lazily]]
*/
def lazilyAsync[T](create: function.Creator[CompletionStage[T]]): Source[T, Future[NotUsed]] =
scaladsl.Source.lazilyAsync[T](() create.create().toScala).asJava
/**
* Creates a `Source` that is materialized as a [[org.reactivestreams.Subscriber]]
*/