RxScala's map() function

Like the Scala language, RxScala also has a map() function. In RxScala, Observable's map() function returns an Observable that applies the given function to each item emitted by an Observable and emits the result. It is defined as follows:

def map[R](func: T => R): Observable[R] 

The following example demonstrates how Observable's map() function works:

RxScalaMapFunctionExample.scala:

import rx.lang.scala.Observable 
object RxScalaMapFunctionExample extends App { 
 
  val observable = Observable.just(1) 
 
  observable.map(x => x) 
} 

RxScala's map() function Marble diagram is represented as follows:

RxScala's distinct() function ...

Get Scala Reactive Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.