Skip to content

Commit b7adcf4

Browse files
committed
Fix @UserStorage
1 parent 05e76b2 commit b7adcf4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Sources/SwiftUIX/Intramodular/Dynamic Properties/UserStorage.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ public struct UserStorage<Value: Codable>: DynamicProperty {
3030

3131
@PersistentObject private var valueBox: ValueBox
3232

33+
@State private var foo: Bool = false
34+
3335
public var wrappedValue: Value {
3436
get {
3537
let result: Value = valueBox.value
3638

39+
valueBox.foo = foo
40+
3741
return result
3842
} nonmutating set {
43+
foo.toggle()
44+
45+
valueBox.foo = foo
3946
valueBox.value = newValue
4047
}
4148
}
@@ -188,15 +195,12 @@ extension UserStorage: Equatable where Value: Equatable {
188195

189196
extension UserStorage {
190197
private class ValueBox: ObservableObject {
198+
fileprivate var foo: Bool = false
191199
fileprivate var _SwiftUI_DynamicProperty_update_called: Bool = false
192-
193-
var configuration: UserStorageConfiguration<Value>
194-
200+
fileprivate var configuration: UserStorageConfiguration<Value>
195201
fileprivate var storedValue: Value?
196-
197-
private var storeSubscription: AnyCancellable?
198-
199-
private var _isEncodingValueToStore: Bool = false
202+
fileprivate var storeSubscription: AnyCancellable?
203+
fileprivate var _isEncodingValueToStore: Bool = false
200204

201205
var value: Value {
202206
get {

0 commit comments

Comments
 (0)