diff --git a/Sources/BSWInterfaceKit/SwiftUI/Extensions/EnvironmentObject+Optional.swift b/Sources/BSWInterfaceKit/SwiftUI/Extensions/EnvironmentObject+Optional.swift index 0005add0..037d74b2 100644 --- a/Sources/BSWInterfaceKit/SwiftUI/Extensions/EnvironmentObject+Optional.swift +++ b/Sources/BSWInterfaceKit/SwiftUI/Extensions/EnvironmentObject+Optional.swift @@ -24,23 +24,26 @@ extension EnvironmentObject { // MARK: - API extension EnvironmentObject.Optional { - @dynamicMemberLookup - @frozen - public struct Wrapper { - fileprivate let base: EnvironmentObject.Optional - public subscript(dynamicMember keyPath: ReferenceWritableKeyPath) -> Binding { - Binding(get: { - self.base.wrappedValue?[keyPath: keyPath] - }, set: { - if let newValue = $0 { - self.base.wrappedValue?[keyPath: keyPath] = newValue - } else { - assertionFailure("Cannot write back Optional.none to a non-Optional value.") + @MainActor + @dynamicMemberLookup + @frozen + public struct Wrapper { + + fileprivate let base: EnvironmentObject.Optional + + public subscript(dynamicMember keyPath: ReferenceWritableKeyPath) -> Binding { + Binding(get: { + self.base.wrappedValue?[keyPath: keyPath] + }, set: { + if let newValue = $0 { + self.base.wrappedValue?[keyPath: keyPath] = newValue + } else { + assertionFailure("Cannot write back Optional.none to a non-Optional value.") + } + }) } - }) } - } } // MARK: - Auxiliary