contramap
Transform this Flow by applying a function to each incoming upstream element before it is passed to the Flow.
Signature
Flow.contramap
Flow.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
-
source
import 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