collect static method

List<Future<Fractal?>> collect(
  1. Iterable<Map> frags
)

Implementation

static List<Future<Fractal?>> collect(Iterable<Map> frags) {
  //Map<String, List<int>> collecting = {};
  final fus = <Future<Fractal?>>[];
  var need = 0;
  for (var m in frags) {
    final id = m['id'];

    if (Fractal.storage[id] case Fractal f) {
      fus.add(Future.value(f));
      continue;
    }

    var c = comp[id];
    if (c == null) {
      comp[id] = c = Completer();
      final type = m['type'];
      final ids = collecting[type] ??= [];
      if (!ids.contains(id)) {
        ids.add(id);
        need++;
      }
    }

    fus.add(c.future);
  }

  if (need > 0) timerC.hold(_collect, 30);

  /*
  for (var item in frags) {
    await Fractal.storage.request(item['id']);
  }
  */

  return fus;
}