forEachAsync<V> function

Future<void> forEachAsync<V>(
  1. Iterable<V> source,
  2. Future<void> forEach(
    1. V elemente
    ), [
  3. int parallels = 1
])

Iterable elements of source with support async function and runs it's in parallels

Implementation

Future<void> forEachAsync<V>(
    Iterable<V> source, Future<void> Function(V elemente) forEach,
    [int parallels = 1]) async {
  for (final Iterable<V> group in groupBySize<V>(source, parallels)) {
    await Future.wait(group.map(forEach));
  }
}