reduceAsync<S, T> function

  1. @Deprecated('Use Future.doWhile from dart:async. Will be removed in 3.0.0.')
Future<S> reduceAsync <S, T>(
  1. Iterable<T> iterable,
  2. S initialValue,
  3. AsyncCombiner<S, T> combine
)

Reduces a collection to a single value by iteratively combining elements of the collection using the provided combine function. Similar to Iterable.reduce, except that combine is an async function that returns a Future.

This is deprecated and will be removed in Quiver 3.0.0. It can be replaced with Future.forEach as follows:

List<int> myList = ...
int sum = await reduceAsync(myList, 0, (int a, int b) {
  return a + b;
});

can be replaced by the following code:

List<int> myList = ...
int sum = 0;
await Future.forEach(myList, (int i) {
  sum += i;
});

Implementation

@Deprecated('Use Future.doWhile from dart:async. Will be removed in 3.0.0.')
Future<S> reduceAsync<S, T>(
        Iterable<T> iterable, S initialValue, AsyncCombiner<S, T> combine) =>
    _reduceAsync(iterable.iterator, initialValue, combine);