flatAndCollectAsync<T, X> method

Future<Response<List<T>>> flatAndCollectAsync<T, X>(
  1. Iterable<X> source,
  2. Future<Response<T>> mapper(
    1. X source
    )
)

Implementation

Future<Response<List<T>>> flatAndCollectAsync<T, X>(
  Iterable<X> source,
  Future<Response<T>> Function(X source) mapper,
) async {
  var response = Responses.success<List<T>>([]);
  for (var id in source) {
    response = await response.flatMapAsync((tab) => mapper(id).mapToResponse((t) => tab!.appendInPlace(t!)));
  }
  return response;
}