delete method

Future<void> delete(
  1. CItem<T> item, {
  2. bool cascade = false,
})

Deletes item and every one of its recipient copies. Only the owner may call this. Throws CollectionOpException on any key-level failure.

If cascade is false (the default) and item has self-owned descendants in any sub-collection, throws StateError and does not write anything — the caller must either delete descendants explicitly or pass cascade: true.

If cascade is true, every self-owned descendant (at any depth) is deleted before item itself.

Implementation

Future<void> delete(CItem<T> item, {bool cascade = false}) async {
  final results = await _delete(item, cascade: cascade);
  if (results.any((r) => r is OpFailure)) {
    throw CollectionOpException(results);
  }
  await _awaitLocalEmissions();
}