Files
plezy/lib/utils/library_refresh_notifier.dart
T
edde746 0c23de9ede feat: library overhaul
add collections, library specific home screen, and more
2025-11-16 20:53:59 +01:00

39 lines
1.1 KiB
Dart

import 'dart:async';
/// Notifier for triggering refreshes of library tabs
/// Singleton pattern for global access
class LibraryRefreshNotifier {
static final LibraryRefreshNotifier _instance = LibraryRefreshNotifier._internal();
factory LibraryRefreshNotifier() => _instance;
LibraryRefreshNotifier._internal();
// Stream controllers for different tab types
final _collectionsController = StreamController<void>.broadcast();
final _playlistsController = StreamController<void>.broadcast();
// Streams that tabs can listen to
Stream<void> get collectionsStream => _collectionsController.stream;
Stream<void> get playlistsStream => _playlistsController.stream;
// Methods to trigger refreshes
void notifyCollectionsChanged() {
if (!_collectionsController.isClosed) {
_collectionsController.add(null);
}
}
void notifyPlaylistsChanged() {
if (!_playlistsController.isClosed) {
_playlistsController.add(null);
}
}
// Cleanup
void dispose() {
_collectionsController.close();
_playlistsController.close();
}
}