RxJava



rx.operators
Class OperationMap

java.lang.Object
  extended by rx.operators.OperationMap

public final class OperationMap
extends java.lang.Object

Applies a function of your choosing to every item emitted by an Observable, and returns this transformation as a new Observable.


Constructor Summary
OperationMap()
           
 
Method Summary
static
<T,R> Observable.OnSubscribeFunc<R>
map(Observable<? extends T> sequence, Func1<? super T,? extends R> func)
          Accepts a sequence and a transformation function.
static
<T,R> Observable.OnSubscribeFunc<R>
mapMany(Observable<? extends T> sequence, Func1<? super T,? extends Observable<? extends R>> func)
          Accepts a sequence of observable sequences and a transformation function.
static
<T,R> Observable.OnSubscribeFunc<R>
mapWithIndex(Observable<? extends T> sequence, Func2<? super T,java.lang.Integer,? extends R> func)
          Accepts a sequence and a transformation function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationMap

public OperationMap()
Method Detail

map

public static <T,R> Observable.OnSubscribeFunc<R> map(Observable<? extends T> sequence,
                                                      Func1<? super T,? extends R> func)
Accepts a sequence and a transformation function. Returns a sequence that is the result of applying the transformation function to each item in the sequence.

Type Parameters:
T - the type of the input sequence.
R - the type of the output sequence.
Parameters:
sequence - the input sequence.
func - a function to apply to each item in the sequence.
Returns:
a sequence that is the result of applying the transformation function to each item in the input sequence.

mapWithIndex

public static <T,R> Observable.OnSubscribeFunc<R> mapWithIndex(Observable<? extends T> sequence,
                                                               Func2<? super T,java.lang.Integer,? extends R> func)
Accepts a sequence and a transformation function. Returns a sequence that is the result of applying the transformation function to each item in the sequence.

Type Parameters:
T - the type of the input sequence.
R - the type of the output sequence.
Parameters:
sequence - the input sequence.
func - a function to apply to each item in the sequence. The function gets the index of the emitted item as additional parameter.
Returns:
a sequence that is the result of applying the transformation function to each item in the input sequence.

mapMany

public static <T,R> Observable.OnSubscribeFunc<R> mapMany(Observable<? extends T> sequence,
                                                          Func1<? super T,? extends Observable<? extends R>> func)
Accepts a sequence of observable sequences and a transformation function. Returns a flattened sequence that is the result of applying the transformation function to each item in the sequence of each observable sequence.

The closure should return an Observable which will then be merged.

Type Parameters:
T - the type of the input sequence.
R - the type of the output sequence.
Parameters:
sequence - the input sequence.
func - a function to apply to each item in the sequence.
Returns:
a sequence that is the result of applying the transformation function to each item in the input sequence.