From cd5545bdc848acc21e1f1cd3eada1d53d4f58aa1 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Tue, 7 May 2024 17:37:44 +0000 Subject: [PATCH] fix(datastore): memory leak in ModelSyncedEventEmitter (#3675) * fix(datastore): memory leak in ModelSyncedEventEmitter * resolve lint comments --- .../Sync/InitialSync/ModelSyncedEventEmitter.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/ModelSyncedEventEmitter.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/ModelSyncedEventEmitter.swift index 9a44dbbc45..8e59168d0d 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/ModelSyncedEventEmitter.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/ModelSyncedEventEmitter.swift @@ -65,7 +65,7 @@ final class ModelSyncedEventEmitter { self.syncOrchestratorSink = initialSyncOrchestrator? .publisher .receive(on: queue) - .filter(filterSyncOperationEvent(_:)) + .filter { [weak self] in self?.filterSyncOperationEvent($0) == true } .sink(receiveCompletion: { _ in }, receiveValue: { [weak self] value in self?.onReceiveSyncOperationEvent(value: value) @@ -74,7 +74,7 @@ final class ModelSyncedEventEmitter { self.reconciliationQueueSink = reconciliationQueue? .publisher .receive(on: queue) - .filter(filterReconciliationQueueEvent(_:)) + .filter { [weak self] in self?.filterReconciliationQueueEvent($0) == true } .sink(receiveCompletion: { _ in }, receiveValue: { [weak self] value in self?.onReceiveReconciliationEvent(value: value)