diff --git a/Decide-Tests/SwiftUI_Tests.swift b/Decide-Tests/SwiftUI_Tests.swift index bc18c1e..08b39f3 100644 --- a/Decide-Tests/SwiftUI_Tests.swift +++ b/Decide-Tests/SwiftUI_Tests.swift @@ -26,9 +26,13 @@ import DecideTesting struct ViewUnderTest: View { @BindKeyed(\State.$strMutable) var strMutable + @ObserveKeyed(\State.$str) var str + @ObserveKeyed(\State.$strMutable) var strMutableObserved var body: some View { TextField("", text: strMutable[1]) + Text(str[1]) + Text(strMutableObserved[1]) } } diff --git a/Decide/Accessor/SwiftUI/ObserveKeyed.swift b/Decide/Accessor/SwiftUI/ObserveKeyed.swift index eef0f0e..34e9fc9 100644 --- a/Decide/Accessor/SwiftUI/ObserveKeyed.swift +++ b/Decide/Accessor/SwiftUI/ObserveKeyed.swift @@ -27,7 +27,13 @@ import SwiftUI let propertyKeyPath: KeyPath> - public init(_ propertyKeyPath: KeyPath>) { + public init(_ propertyKeyPath: KeyPath>) { + self.propertyKeyPath = propertyKeyPath + } + + public init( + _ propertyKeyPath: KeyPath + ) where P.Value == Value { self.propertyKeyPath = propertyKeyPath.appending(path: \.wrappedValue) }