scan<S> method

Stream<S> scan<S>(
  1. S accumulator(
    1. S accumulated,
    2. T value,
    3. int index
    ),
  2. S seed
)

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

Example

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

Implementation

Stream<S> scan<S>(
        S Function(S accumulated, T value, int index) accumulator, S seed) =>
    ScanStreamTransformer<T, S>(accumulator, seed).bind(this);