From 27a9711f3d9e086eda697c8833dc6c39fbf71c8a Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Tue, 30 Apr 2024 16:08:44 -0700 Subject: [PATCH] weak self dance to avoid retain loop --- Sources/AutomergeRepo/Repo.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/AutomergeRepo/Repo.swift b/Sources/AutomergeRepo/Repo.swift index 3e59d0d..a69df4a 100644 --- a/Sources/AutomergeRepo/Repo.swift +++ b/Sources/AutomergeRepo/Repo.swift @@ -256,7 +256,8 @@ public final class Repo { if let doc = handle.doc, handle.state == .ready, observerHandles[id] == nil { let handleObserver = doc.objectWillChange .debounce(for: saveDebounce, scheduler: RunLoop.main) - .sink { _ in + .sink { [weak self] _ in + guard let self else { return } for peer in self.peerMetadataByPeerId.keys { Task { await self.beginSync(docId: id, to: peer)