diff --git a/Documentation/Reference/structs/State.md b/Documentation/Reference/structs/State.md index c111931..5871809 100644 --- a/Documentation/Reference/structs/State.md +++ b/Documentation/Reference/structs/State.md @@ -13,6 +13,10 @@ Access the stored value. This updates the views when being changed. Get the value as a binding using the `$` prefix. +### `rawValue` + +Get and set the value without updating the views. + ### `content` The stored value. diff --git a/Sources/Adwaita/Model/Data Flow/State.swift b/Sources/Adwaita/Model/Data Flow/State.swift index 5fcd7da..e2651b7 100644 --- a/Sources/Adwaita/Model/Data Flow/State.swift +++ b/Sources/Adwaita/Model/Data Flow/State.swift @@ -11,18 +11,16 @@ import Foundation @propertyWrapper public struct State: StateProtocol { - // swiftlint:disable force_cast /// Access the stored value. This updates the views when being changed. public var wrappedValue: Value { get { - content.storage.value as! Value + rawValue } nonmutating set { - content.storage.value = newValue + rawValue = newValue Self.updateViews() } } - // swiftlint:enable force_cast /// Get the value as a binding using the `$` prefix. public var projectedValue: Binding { @@ -33,6 +31,18 @@ public struct State: StateProtocol { } } + // swiftlint:disable force_cast + /// Get and set the value without updating the views. + public var rawValue: Value { + get { + content.storage.value as! Value + } + nonmutating set { + content.storage.value = newValue + } + } + // swiftlint:enable force_cast + /// The stored value. public let content: State.Content