Source.unfoldResourceAsync

Wrap any resource that can be opened, queried for next element (in a blocking way) and closed using three distinct functions into a source.

Source operators

Signature

def unfoldResourceAsync[T, S](create: () ⇒ Future[S], read: (S) ⇒ Future[Option[T]], close: (S) ⇒ Future[Done]): Source[T, NotUsed]

Description

Wrap any resource that can be opened, queried for next element (in a blocking way) and closed using three distinct functions into a source. Functions return Future CompletionStage to achieve asynchronous processing

emits when there is demand and Future CompletionStage from read function returns value

completes when Future CompletionStage from read function returns None

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.