Correct way to use AppDependencyManager

Hi in the CometCal sample they have this:

@main
struct CometCalApp: App {
    
    init() {
        let dependency = CalendarManager.shared
        AppDependencyManager.shared.add(dependency: dependency)
    }

    var body: some Scene {
        WindowGroup {
            CalendarListView()
        }
        .modelContainer(CalendarManager.shared.modelContainer)
    }
}

However I do not want my manager to init when I am using SwiftUI previews. FYI in SwiftUI previews the App is init but body isn't called. So I require the CalendarManager to be init lazily. Is this a valid way to achieve that:

    init() {
        let dependency: @Sendable () async -> (CalendarManager) =  { @MainActor in
            return CalendarManager.shared
        }
        AppDependencyManager.shared.add(dependency:  dependency)
    }

If so it would be great if the API could be improved to let me just do this:

AppDependencyManager.shared.add(dependency:  CalendarManager.shared)

Which currently fails with Main actor-isolated static property 'shared' can not be referenced from a Sendable closure

Thanks!

Correct way to use AppDependencyManager
 
 
Q