createFrom<T, X> static method

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

Implementation

static Response<List<T>> createFrom<T, X>(
  Iterable<X> source,
  Response<T> Function(X source) mapper,
) {
  var response = Responses.success<List<T>>([]);
  for (var id in source) {
    response = response.flatMap((tab) => mapper(id).map((t) => tab!.appendInPlace(t!)));
  }
  return response;
}