map

Transform each element in the stream by calling a mapping function with it and passing the returned value downstream.

Simple operators

Signature

Source.mapSource.map Flow.mapFlow.map

Description

Transform each element in the stream by calling a mapping function with it and passing the returned value downstream.

Examples

Scala
sourceimport akka.NotUsed
import akka.stream.scaladsl._

val source: Source[Int, NotUsed] = Source(1 to 10)
val mapped: Source[String, NotUsed] = source.map(elem => elem.toString)

Reactive Streams semantics

emits when the mapping function returns an element

backpressures when downstream backpressures

completes when upstream completes

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.