From d10437ee6483633dc551136251bfaebef03996f7 Mon Sep 17 00:00:00 2001 From: Pim Date: Fri, 24 Feb 2023 12:09:17 +0100 Subject: [PATCH] Use up-to-date storage --- Sources/DidUpdate/ObservedValue.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/DidUpdate/ObservedValue.swift b/Sources/DidUpdate/ObservedValue.swift index 6afbda6..a40f26c 100644 --- a/Sources/DidUpdate/ObservedValue.swift +++ b/Sources/DidUpdate/ObservedValue.swift @@ -37,9 +37,10 @@ public struct ObservedValue { storage storageKeyPath: ReferenceWritableKeyPath ) -> ReadOnlyProxy { get { - let storage = instance[keyPath: storageKeyPath] return ReadOnlyProxy( - get: { storage.storage }, + get: { + instance[keyPath: storageKeyPath].storage + }, updateHandler: { instance.addObserver(keyPath: storageKeyPath, handler: $0) } ) }