contramap

Transform this Flow by applying a function to each incoming upstream element before it is passed to the Flow.

Simple operators

Signature

Flow.contramapFlow.contramap

Description

Transform this Flow by applying a function to each incoming upstream element before it is passed to the Flow.

Examples

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

val flow: Flow[Int, Int, NotUsed] = Flow[Int]
val newFlow: Flow[String, Int, NotUsed] = flow.contramap(_.toInt)

Reactive Streams semantics

emits when the mapping function returns an element

backpressures ’‘‘Backpressures when’’’ original flow backpressures

completes when upstream completes

cancels when original flow cancels