clear method

void clear()

Removes every mutation, one MutationRemoved each. QueryClient.clear calls this together with the query cache's.

Running mutations stop retrying, as with remove, and clear() never starts a mutation that was queued in a MutationScope. The events are emitted after every entry is gone, so a listener sees the cache in its final state and a clear() it re-enters finds nothing left to remove.

Implementation

void clear() {
  final removed = mutations;
  _mutations.clear();
  _removedRunningHeads.clear();
  for (final mutation in removed) {
    mutation.destroy();
  }
  for (final mutation in removed) {
    notify(MutationRemoved(mutation));
  }
}