retainOnly method

int retainOnly(
  1. Iterable<String> keep
)

Lets go of every model not at a path in keep — what a level no longer draws leaves the GPU — and tells listeners of each. A model still loading is kept; one asked for again loads again. Returns how many went.

Implementation

int retainOnly(Iterable<String> keep) {
  final kept = keep is Set<String> ? keep : keep.toSet();
  final gone = [
    for (final MapEntry(:key, :value) in _entries.entries)
      if (!kept.contains(key) && value.isSettled) key,
  ];
  for (final path in gone) {
    _entries.remove(path);
    _notify(path);
  }
  return gone.length;
}