diff --git a/LeStorage/StoredSingleton.swift b/LeStorage/StoredSingleton.swift index 459da1c..35dc82d 100644 --- a/LeStorage/StoredSingleton.swift +++ b/LeStorage/StoredSingleton.swift @@ -27,10 +27,11 @@ public class StoredSingleton: SyncedCollection { return self.items.first } - @discardableResult public func tryPutBeforeUpdating(_ instance: T) async throws -> T? { + public func tryPutBeforeUpdating(_ instance: T) async throws { let result = try await StoreCenter.main.service().rawPut(instance) - self.setItemNoSync(result) - return result + if let item = self.item() { + item.copy(from: result) + } } // MARK: - Protects from use