scan<S> method

Observable<S> scan <S>(S accumulator(S accumulated, T value, int index), [ S seed ])

Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.

Example

new Observable.fromIterable([1, 2, 3])
   .scan((acc, curr, i) => acc + curr, 0)
   .listen(print); // prints 1, 3, 6

Implementation

Observable<S> scan<S>(S accumulator(S accumulated, T value, int index),
        [S seed]) =>
    transform(new ScanStreamTransformer<T, S>(accumulator, seed));