diff --git a/LeStorage/StoredSingleton.swift b/LeStorage/StoredSingleton.swift index 89f439d..2f3435e 100644 --- a/LeStorage/StoredSingleton.swift +++ b/LeStorage/StoredSingleton.swift @@ -27,6 +27,13 @@ public class StoredSingleton: SyncedCollection { return self.items.first } + public func tryPutBeforeUpdating(_ instance: T) async throws { + if let result = try await StoreCenter.main.service().put(instance) { + self.setItemNoSync(result) + } + } + + // MARK: - Protects from use public override func addOrUpdate(contentOfs sequence: any Sequence) {