native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
713 B · 30 lines
Swift
12345678910111213141516171819202122232425262728293031import AppKitimport ComposableArchitecture
struct AppLifecycleClient: Sendable { var surfaceMainWindow: @MainActor @Sendable () -> Bool var terminate: @MainActor @Sendable () -> Void}
extension AppLifecycleClient: DependencyKey { static let liveValue = AppLifecycleClient( surfaceMainWindow: { NSApplication.shared.surfaceMainWindow() }, terminate: { NSApplication.shared.terminate(nil) } )
static let testValue = AppLifecycleClient( surfaceMainWindow: { false }, terminate: {} )}
extension DependencyValues { var appLifecycleClient: AppLifecycleClient { get { self[AppLifecycleClient.self] } set { self[AppLifecycleClient.self] = newValue } }}