From d6d3699fbad875e620cf39806315b2109401b9c3 Mon Sep 17 00:00:00 2001 From: Andrew Mayers Date: Tue, 15 Jul 2025 09:06:44 -0400 Subject: [PATCH] Add a read only subscript to ObservableModel https://square.slack.com/archives/CBZJ5V163/p1751313246347059 --- WorkflowSwiftUI/Sources/ObservableModel.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WorkflowSwiftUI/Sources/ObservableModel.swift b/WorkflowSwiftUI/Sources/ObservableModel.swift index 2a22b7c32..1c8d4cedd 100644 --- a/WorkflowSwiftUI/Sources/ObservableModel.swift +++ b/WorkflowSwiftUI/Sources/ObservableModel.swift @@ -147,4 +147,9 @@ extension ObservableModel { accessor.sendValue { $0[keyPath: keyPath] = newValue } } } + + /// Allows dynamic member lookup to read state through the accessor. + public subscript(dynamicMember keyPath: KeyPath) -> T { + accessor.state[keyPath: keyPath] + } }