mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 05:33:31 +01:00
allow ListPublisher and ObjectPublisher combine Publishers to cancel subscription from any thread
This commit is contained in:
@@ -135,8 +135,19 @@ extension ListPublisher {
|
||||
|
||||
func cancel() {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
self.subscriber = nil
|
||||
|
||||
if Thread.isMainThread {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
}
|
||||
else {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,8 +135,19 @@ extension ObjectPublisher {
|
||||
|
||||
func cancel() {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
self.subscriber = nil
|
||||
|
||||
if Thread.isMainThread {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
}
|
||||
else {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
self.publisher.removeObserver(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user