traverseListWithIndex<E, A, B> static method

TaskEither<E, List<B>> traverseListWithIndex<E, A, B>(
  1. List<A> list,
  2. TaskEither<E, B> f(
    1. A a,
    2. int i

Map each element in the list to a TaskEither using the function f, and collect the result in an TaskEither<E, List<B>>.

Each TaskEither is executed in parallel. This strategy is faster than sequence, but the order of the request is not guaranteed.

If you need TaskEither to be executed in sequence, use traverseListWithIndexSeq.

Same as TaskEither.traverseList but passing index in the map function.


static TaskEither<E, List<B>> traverseListWithIndex<E, A, B>(
  List<A> list,
  TaskEither<E, B> Function(A a, int i) f,
) =>
    TaskEither<E, List<B>>(
      () async => Either.sequenceList(
        await Task.traverseListWithIndex<A, Either<E, B>>(
          (a, i) => Task(() => f(a, i).run()),