diff --git a/src/sqlite/SQLiteResultPublisher.swift b/src/sqlite/SQLiteResultPublisher.swift index 0d645d3c8..248443ea4 100644 --- a/src/sqlite/SQLiteResultPublisher.swift +++ b/src/sqlite/SQLiteResultPublisher.swift @@ -9,11 +9,10 @@ enum SQLiteSubscriptionType { final class SQLiteSubscription: Workspace.Subscription { private let ofType: SQLiteSubscriptionType var cancelled = UnsafeAtomic.Storage(false) - let identifier: ObjectIdentifier + var identifier: ObjectIdentifier { ObjectIdentifier(self) } weak var workspace: SQLiteWorkspace? - init(ofType: SQLiteSubscriptionType, identifier: ObjectIdentifier, workspace: SQLiteWorkspace) { + init(ofType: SQLiteSubscriptionType, workspace: SQLiteWorkspace) { self.ofType = ofType - self.identifier = identifier self.workspace = workspace } deinit { diff --git a/src/sqlite/SQLiteWorkspace.swift b/src/sqlite/SQLiteWorkspace.swift index dc524e559..3233fe52b 100644 --- a/src/sqlite/SQLiteWorkspace.swift +++ b/src/sqlite/SQLiteWorkspace.swift @@ -259,7 +259,7 @@ public final class SQLiteWorkspace: Workspace { public func subscribe(fetchedResult: FetchedResult, changeHandler: @escaping (_: FetchedResult) -> Void) -> Workspace.Subscription where Element: Equatable { let fetchedResult = fetchedResult as! SQLiteFetchedResult let identifier = ObjectIdentifier(fetchedResult.query) - let subscription = SQLiteSubscription(ofType: .fetchedResult(Element.self, identifier), identifier: ObjectIdentifier(changeHandler as AnyObject), workspace: self) + let subscription = SQLiteSubscription(ofType: .fetchedResult(Element.self, identifier), workspace: self) guard !(withUnsafeMutablePointer(to: &state.shutdown) { UnsafeAtomic(at: $0).load(ordering: .acquiring) }) else { return subscription } @@ -305,7 +305,7 @@ public final class SQLiteWorkspace: Workspace { } public func subscribe(object: Element, changeHandler: @escaping (_: SubscribedObject) -> Void) -> Workspace.Subscription where Element: Equatable { - let subscription = SQLiteSubscription(ofType: .object(Element.self, object._rowid), identifier: ObjectIdentifier(changeHandler as AnyObject), workspace: self) + let subscription = SQLiteSubscription(ofType: .object(Element.self, object._rowid), workspace: self) guard !(withUnsafeMutablePointer(to: &state.shutdown) { UnsafeAtomic(at: $0).load(ordering: .acquiring) }) else { return subscription }