doOnFirst

Run the given function when the first element is received.

Simple operators

Signature

Source.doOnFirstSource.doOnFirst Flow.doOnFirstFlow.doOnFirst

Description

Run the given function when the first element is received.

Examples

Scala
sourceimport org.apache.pekko
import pekko.NotUsed
import pekko.stream.scaladsl._

val source: Source[Int, NotUsed] = Source(1 to 10)
val mapped: Source[Int, NotUsed] = source.doOnFirst(println)

Reactive Streams semantics

emits when upstream emits an element

backpressures when downstream backpressures

completes when upstream completes