Files
Client/lib/utils/cache_invalidation_bus.dart
T

21 lines
839 B
Dart

import 'dart:async';
/// App-wide pub/sub channel for cache invalidations. Producers (e.g. webdav
/// move/delete handlers) call [notifyListFiles] after they have dropped the
/// cached listing for a folder so that any [_FilesView] currently sitting on
/// that folder — possibly in the background, beneath a child route — can
/// refresh itself instead of showing the stale snapshot it loaded earlier.
class CacheInvalidationBus {
CacheInvalidationBus._();
static final StreamController<String> _listFiles = StreamController<String>.broadcast();
/// Emits the invalidated `pathString` (in `FilesBloc` format: relative,
/// no leading or trailing slash; root is '/').
static Stream<String> get listFilesStream => _listFiles.stream;
static void notifyListFiles(String pathString) {
_listFiles.add(pathString);
}
}