import Foundation import SwiftData /// Owns all service objects; created asynchronously at launch and injected /// into the SwiftUI environment. @Observable @MainActor final class AppServices { let modelContainer: ModelContainer let syncEngine: SyncEngine let contextService: ContextService init() async { let container = NotesModelContainer.make() self.modelContainer = container self.syncEngine = SyncEngine(modelContainer: container) self.contextService = ContextService() } /// Slow startup work (iCloud container discovery) — runs after the UI is up. func startDeferredServices() async { await syncEngine.connect() } }