RxJava



rx.operators
Class OperationScan

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

public final class OperationScan
extends java.lang.Object

Returns an Observable that applies a function to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.

This sort of function is sometimes called an accumulator.

Note that when you pass a seed to scan() the resulting Observable will emit that seed as its first emitted item.


Constructor Summary
OperationScan()
           
 
Method Summary
static
<T> Observable.OnSubscribeFunc<T>
scan(Observable<? extends T> sequence, Func2<T,T,T> accumulator)
          Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.
static
<T,R> Observable.OnSubscribeFunc<R>
scan(Observable<? extends T> sequence, R initialValue, Func2<R,? super T,R> accumulator)
          Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationScan

public OperationScan()
Method Detail

scan

public static <T,R> Observable.OnSubscribeFunc<R> scan(Observable<? extends T> sequence,
                                                       R initialValue,
                                                       Func2<R,? super T,R> accumulator)
Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

Parameters:
sequence - An observable sequence of elements to project.
initialValue - The initial (seed) accumulator value.
accumulator - An accumulator function to be invoked on each element from the sequence.
Returns:
An observable sequence whose elements are the result of accumulating the output from the list of Observables.
See Also:
Observable.Scan(TSource, TAccumulate) Method (IObservable(TSource), TAccumulate, Func(TAccumulate, TSource, TAccumulate))

scan

public static <T> Observable.OnSubscribeFunc<T> scan(Observable<? extends T> sequence,
                                                     Func2<T,T,T> accumulator)
Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator.

Parameters:
sequence - An observable sequence of elements to project.
accumulator - An accumulator function to be invoked on each element from the sequence.
Returns:
An observable sequence whose elements are the result of accumulating the output from the list of Observables.
See Also:
Observable.Scan(TSource) Method (IObservable(TSource), Func(TSource, TSource, TSource))