foreach

Invoke a given procedure for each element received.

Sink operators

Signature

def foreach[T](f: T => Unit): Sink[T, Future[Done]]

Description

Invoke a given procedure for each element received. Note that it is not safe to mutate shared state from the procedure.

The sink materializes into a Future[Option[Done]] CompletionStage<Optional<Done> which completes when the stream completes, or fails if the stream fails.

Note that it is not safe to mutate state from the procedure.

cancels never

backpressures when the previous procedure invocation has not yet completed

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.