retainNewest method

  1. @override
  2. @nonVirtual
Future<void> retainNewest(
  1. int count
)
override

Keeps the count newest entries (onRetainNewest) and sends LogEntriesRemovedById with the removed ids, nothing if there was nothing to remove, or LogStoreInvalidated if the store does not know what it removed. Throws StateError after close.

Implementation

@override
@nonVirtual
Future<void> retainNewest(int count) async {
  assert(count >= 0, 'count must not be negative');
  _checkOpen();
  final removed = await onRetainNewest(count);
  if (removed == null) {
    _emit(const LogStoreInvalidated());
  } else if (removed.isNotEmpty) {
    _emit(LogEntriesRemovedById(removed));
  }
}