Skip to content

Commit

Permalink
Add objectWillChange notification (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Jan 25, 2024
1 parent 662afd6 commit c72c820
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ extension Application.DependencySlice where SliceKeyPath == WritableKeyPath<Valu
/// The current dependency value.
public var value: SliceValue {
get { dependency.value[keyPath: keyPath] }
set { dependency.value[keyPath: keyPath] = newValue }
set {
#if !os(Linux) && !os(Windows)
Application.shared.objectWillChange.send()
#endif
dependency.value[keyPath: keyPath] = newValue
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ extension Application {
return storedValue
}
set {
defer {
shared.objectWillChange.send()
}

shared.objectWillChange.send()

guard let newValue else {
return keychain.remove(scope.key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ import SwiftUI
)

var dependency = app.value(keyPath: dependencyKeyPath)
#if !os(Linux) && !os(Windows)
Application.shared.objectWillChange.send()
#endif
dependency.value[keyPath: valueKeyPath] = newValue
}
}
Expand Down

0 comments on commit c72c820

Please sign in to comment.