traverseListWithIndexSeq<E, A, B> static method
- List<
A> list, - TaskEither<
E, B> f(- A a,
- 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 sequence. This strategy takes more time than parallel, but it ensures that all the request are executed in order.
If you need TaskEither to be executed in parallel, use traverseListWithIndex
.
Same as TaskEither.traverseList
but passing index
in the map function.
Implementation
static TaskEither<E, List<B>> traverseListWithIndexSeq<E, A, B>(
List<A> list,
TaskEither<E, B> Function(A a, int i) f,
) =>
TaskEither<E, List<B>>(
() async => Either.sequenceList(
await Task.traverseListWithIndexSeq<A, Either<E, B>>(
list,
(a, i) => Task(() => f(a, i).run()),
).run(),
),
);