From 48f0047e0b935542233cc0961115e396deeacb5a Mon Sep 17 00:00:00 2001 From: Thomas Grapperon <35562418+tgrapperon@users.noreply.github.com> Date: Thu, 9 Nov 2023 09:08:43 -0800 Subject: [PATCH] Update UserDefaultsDependency.swift --- Sources/UserDefaultsDependency/UserDefaultsDependency.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/UserDefaultsDependency/UserDefaultsDependency.swift b/Sources/UserDefaultsDependency/UserDefaultsDependency.swift index 9513b7d..4af8f91 100644 --- a/Sources/UserDefaultsDependency/UserDefaultsDependency.swift +++ b/Sources/UserDefaultsDependency/UserDefaultsDependency.swift @@ -272,12 +272,12 @@ extension UserDefaults.Dependency: TestDependencyKey { return UserDefaults.Dependency { key, _ in storage.value[key] } set: { value, key in - var valueDidChange = false + let valueDidChange = LockIsolated(false) storage.withValue { - valueDidChange = !_isEqual($0[key], value) + valueDidChange.setValue(!_isEqual($0[key], value)) $0[key] = value } - if valueDidChange { + if valueDidChange.value { for continuation in continuations.value[key]?.values ?? [:].values { continuation.yield(value) }