Skip to content

Commit

Permalink
Update to fix a issue with subscription identifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Oct 31, 2020
1 parent d45833b commit 3dc1127
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/sqlite/SQLiteResultPublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ enum SQLiteSubscriptionType {
final class SQLiteSubscription: Workspace.Subscription {
private let ofType: SQLiteSubscriptionType
var cancelled = UnsafeAtomic<Bool>.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 {
Expand Down
4 changes: 2 additions & 2 deletions src/sqlite/SQLiteWorkspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public final class SQLiteWorkspace: Workspace {
public func subscribe<Element: Atom>(fetchedResult: FetchedResult<Element>, changeHandler: @escaping (_: FetchedResult<Element>) -> Void) -> Workspace.Subscription where Element: Equatable {
let fetchedResult = fetchedResult as! SQLiteFetchedResult<Element>
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
}
Expand Down Expand Up @@ -305,7 +305,7 @@ public final class SQLiteWorkspace: Workspace {
}

public func subscribe<Element: Atom>(object: Element, changeHandler: @escaping (_: SubscribedObject<Element>) -> 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
}
Expand Down

0 comments on commit 3dc1127

Please sign in to comment.