refreshCollectionStreams function

Future<void> refreshCollectionStreams(
  1. String collection
)

Refreshes every open query on a collection, after a write.

Each query re-runs itself and pushes its own result, so a stream only ever receives records matching its own filters.

Implementation

Future<void> refreshCollectionStreams(String collection) async {
  final prefix = '$collection:';
  final refreshers = _refreshers.entries
      .where((e) => e.key.startsWith(prefix))
      .map((e) => e.value)
      .toList();

  for (final refresh in refreshers) {
    try {
      await refresh();
    } catch (e) {
      debugPrint('[Koolbase] Stream refresh failed after write: $e');
    }
  }
}