Skip to content

Commit 6c1b4e7

Browse files
committed
'Cancel' for PromiseKit -- fix platform check for 'addObserver' usage
1 parent 0b8ab90 commit 6c1b4e7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/NSNotificationCenter+Promise.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ extension NotificationCenter {
3838
/// Observe the named notification once
3939
public func cancellableObserve(once name: Notification.Name, object: Any? = nil) -> CancellablePromise<Notification> {
4040
let (promise, resolver) = CancellablePromise<Notification>.pending()
41-
#if !os(Linux)
42-
let id = addObserver(forName: name, object: object, queue: nil, using: resolver.fulfill)
43-
#else
41+
#if os(Linux) && ((swift(>=4.0) && !swift(>=4.0.1)) || (swift(>=3.0) && !swift(>=3.2.1)))
4442
let id = addObserver(forName: name, object: object, queue: nil, usingBlock: resolver.fulfill)
45-
#endif
43+
#else
44+
let id = addObserver(forName: name, object: object, queue: nil, using: resolver.fulfill)
45+
#endif
4646

4747
promise.appendCancellableTask(task: ObserverTask { self.removeObserver(id) }, reject: resolver.reject)
4848

0 commit comments

Comments
 (0)