Update Injected state mechanism
This commit is contained in:
parent
428eb32be1
commit
91faf3c0f4
2 changed files with 3 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import Adwaita
|
||||
import Foundation
|
||||
|
||||
public final class DIContainer: @unchecked Sendable {
|
||||
|
|
@ -55,7 +56,7 @@ public final class DIContainer: @unchecked Sendable {
|
|||
|
||||
private func notifyObservers(for keyPath: AnyKeyPath) {
|
||||
let handlers: [@Sendable () -> Void] = lock.withLock {
|
||||
Array(observers[keyPath]?.values ?? [])
|
||||
Array((observers[keyPath] ?? [:]).values)
|
||||
}
|
||||
handlers.forEach { $0() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@ public struct Injected<T> {
|
|||
self.keyPath = keyPath
|
||||
self.observerRef = ObserverRef(
|
||||
id: DIContainer.shared.addObserver(for: keyPath) {
|
||||
Task { @MainActor in
|
||||
StateManager.updateViews()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue