Files
plezy/lib/utils/library_refresh_notifier.dart
T

30 lines
1.0 KiB
Dart
Raw Normal View History

import 'base_notifier.dart';
2025-11-16 20:53:59 +01:00
2025-12-13 00:16:50 +01:00
enum LibraryRefreshType { collections, playlists }
/// Notifier for triggering refreshes of library tabs.
///
/// Singleton pattern with reinitializable state. The controller is lazily
/// created and automatically recreated if disposed and later accessed.
class LibraryRefreshNotifier extends BaseNotifier<LibraryRefreshType> {
2025-12-15 02:29:03 +01:00
static final LibraryRefreshNotifier _instance = LibraryRefreshNotifier._internal();
2025-11-16 20:53:59 +01:00
factory LibraryRefreshNotifier() => _instance;
LibraryRefreshNotifier._internal();
2025-12-13 00:16:50 +01:00
/// Stream for collections tab (backward compatible)
2026-02-15 03:14:04 +01:00
Stream<void> get collectionsStream => stream.where((t) => t == LibraryRefreshType.collections).cast<void>();
2025-11-16 20:53:59 +01:00
2025-12-13 00:16:50 +01:00
/// Stream for playlists tab (backward compatible)
2026-02-15 03:14:04 +01:00
Stream<void> get playlistsStream => stream.where((t) => t == LibraryRefreshType.playlists).cast<void>();
2025-11-16 20:53:59 +01:00
void notifyCollectionsChanged() {
notify(LibraryRefreshType.collections);
2025-11-16 20:53:59 +01:00
}
void notifyPlaylistsChanged() {
notify(LibraryRefreshType.playlists);
2025-11-16 20:53:59 +01:00
}
}