Lazy source (#21081)

This commit is contained in:
Johan "Party Cannon" Andrén 2016-11-25 16:25:26 +01:00 committed by Patrik Nordwall
parent 0d4858c627
commit 267f31149c
7 changed files with 218 additions and 1 deletions

View file

@ -355,6 +355,14 @@ object Source {
DefaultAttributes.failedSource,
shape("FailedSource")))
/**
* Creates a `Source` that is not materialized until there is downstream demand, when the source gets materialized
* the materialized future is completed with its value, if downstream cancels or fails without any demand the
* create factory is never called and the materialized `Future` is failed.
*/
def lazily[T, M](create: () => Source[T, M]): Source[T, Future[M]] =
Source.fromGraph(new LazySource[T, M](create))
/**
* Creates a `Source` that is materialized as a [[org.reactivestreams.Subscriber]]
*/