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 { scala=“#contramapIn2:Flow[In2, Out, Mat]” java=“#map( akka.japi.function.Function)” }

Description

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

Examples

Scala
sourceimport akka.NotUsed
import akka.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

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.