takeFromMapList method

Future takeFromMapList(
  1. Map<K, Iterable<L>> replacement
)

Implementation

Future takeFromMapList(Map<K, Iterable<L>> replacement) async {
  _log.info(
      "sync: ${replacement.isEmpty ? 'empty' : replacement.entries.map((e) => "${e.key}=>${e.value.length}").join(", ")}");
  // Now, let's apply all the childThreads.  This will make sure to remove anything that needs removing, etc.
  await this.removes(replacement).map((removedKey) async {
    _log.fine("sync: key=$removedKey");

    // Instead of removing, just clear out the list.  This ensures that everybody knows about it.
    await this[removedKey]!.sync(<L>[]);
  }).awaitAll();

  await replacement.entries.map((e) async {
    _log.fine("sync: key=$e count${e.value.length}");
    final SunnyObservableList<L> childThreads = this[e.key]!;
    await childThreads.sync(e.value);
  }).awaitAll();
}