Sink.lazyInitAsync

Creates a real Sink upon receiving the first element.

Sink operators

Signature

def lazyInitAsync[T, M](sinkFactory: () => Future[Sink[T, M]]): Sink[T, Future[Option[M]]]

Description

Creates a real Sink upon receiving the first element. Internal Sink will not be created if there are no elements, because of completion or error.

  • If upstream completes before an element was received then the FutureCompletionStage is completed with Nonean empty Optional.
  • If upstream fails before an element was received, sinkFactory throws an exception, or materialization of the internal sink fails then the FutureCompletionStage is completed with the exception.
  • Otherwise the FutureCompletionStage is completed with the materialized value of the internal sink.

cancels never

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.