diff --git a/Sources/WindowTreatment/Modifiers/WindowStateObservingModifier.swift b/Sources/WindowTreatment/Modifiers/WindowStateObservingModifier.swift index ca62996..964a79b 100644 --- a/Sources/WindowTreatment/Modifiers/WindowStateObservingModifier.swift +++ b/Sources/WindowTreatment/Modifiers/WindowStateObservingModifier.swift @@ -31,6 +31,7 @@ extension View { /// Puts the parent window's `WindowStateObserver.State` into the environment. /// /// This makes the state available in child views. It is accessible via the `.windowState` environment key. + @MainActor public func observeWindowState() -> some View { modifier(WindowStateObservingModifier()) } diff --git a/Sources/WindowTreatment/WindowStateObservingView.swift b/Sources/WindowTreatment/WindowStateObservingView.swift index 4deec1f..1cf1275 100644 --- a/Sources/WindowTreatment/WindowStateObservingView.swift +++ b/Sources/WindowTreatment/WindowStateObservingView.swift @@ -18,7 +18,7 @@ public extension EnvironmentValues { struct WindowStateObservingView: NSViewRepresentable { private typealias WindowState = WindowStateObserver.State - @State private var windowState: WindowState = .init(window: nil) + @State private var windowState: WindowState = .init() private let content: Content init(content: () -> Content) {