You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
import '../data/local/local_storage_service.dart';
|
|
import '../data/nostr/nostr_service.dart';
|
|
import '../data/sync/sync_engine.dart';
|
|
import '../data/firebase/firebase_service.dart';
|
|
import '../data/session/session_service.dart';
|
|
import '../data/immich/immich_service.dart';
|
|
import '../data/recipes/recipe_service.dart';
|
|
|
|
/// Container for all application services.
|
|
///
|
|
/// Holds references to all initialized services and provides
|
|
/// a convenient way to dispose of them.
|
|
class AppServices {
|
|
/// Local storage service.
|
|
final LocalStorageService localStorageService;
|
|
|
|
/// Nostr service.
|
|
final NostrService? nostrService;
|
|
|
|
/// Sync engine.
|
|
final SyncEngine? syncEngine;
|
|
|
|
/// Firebase service.
|
|
final FirebaseService? firebaseService;
|
|
|
|
/// Session service.
|
|
final SessionService? sessionService;
|
|
|
|
/// Immich service.
|
|
final ImmichService? immichService;
|
|
|
|
/// Recipe service.
|
|
final RecipeService? recipeService;
|
|
|
|
/// Creates an [AppServices] instance.
|
|
AppServices({
|
|
required this.localStorageService,
|
|
this.nostrService,
|
|
this.syncEngine,
|
|
this.firebaseService,
|
|
this.sessionService,
|
|
this.immichService,
|
|
this.recipeService,
|
|
});
|
|
|
|
/// Disposes of all services that need cleanup.
|
|
Future<void> dispose() async {
|
|
syncEngine?.dispose();
|
|
nostrService?.dispose();
|
|
firebaseService?.dispose();
|
|
|
|
// Close storage service
|
|
try {
|
|
await localStorageService.close();
|
|
} catch (e) {
|
|
// Ignore errors during cleanup
|
|
}
|
|
}
|
|
}
|
|
|