Sink.lazyFutureSink

Defers creation and materialization of a Sink until there is a first element.

Sink operators

Signature

def lazySink[T, M](create: () => Sink[T, M]): Sink[T, Future[M]]

Description

When the first element comes from upstream the Future[Sink] is created. When that completes successfully with a sink that is materialized and inserted in the stream. The internal Sink will not be created if the stream completes of fails before any element got through.

The materialized value of the Sink will be the materialized value of the created internal flow if it is materialized and failed with a akka.stream.NeverMaterializedException if the stream fails or completes without the flow being materialized.

Can be combined with prefixAndTail to base the sink on the first element.

See also lazySink.

Reactive Streams semantics

cancels if the future fails or if the created sink cancels

backpressures when initialized and when created sink backpressures

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.