Skip to content

Commit 69cb157

Browse files
committed
'Cancel' for PromiseKit --
* Delete CancellableGuarantee and all its usages * In PromiseKit Core: instead of using additional functions and methods with the 'CC' suffix, created a new 'cancellable' function to wrap any Promise or Guarantee * In the extensions: Rename methods with 'CC' suffix to 'cancellable' prefix (may revisit this) * Fix the CancellableCatchable 'recover' methods to properly handle cancellation errors * Added an 'afterTask' property to Guarantee, to keep track of the task for calls to 'after'. This way the timer can be appropriately cancelled if the returned Guarantee is passed to the new 'cancellable' function. (may revisit this) * Update all cancellable tests for the cancellable API changes
1 parent b2096d1 commit 69cb157

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Sources/MKDirections+Promise.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ fileprivate class MKDirectionsTask: CancellableTask {
4747

4848
extension MKDirections {
4949
/// Begins calculating the requested route information asynchronously.
50-
public func calculateCC() -> CancellablePromise<MKDirectionsResponse> {
50+
public func cancellableCalculate() -> CancellablePromise<MKDirectionsResponse> {
5151
return CancellablePromise(task: MKDirectionsTask(self)) { calculate(completionHandler: $0.resolve) }
5252
}
5353

5454
/// Begins calculating the requested travel-time information asynchronously.
55-
public func calculateETACC() -> CancellablePromise<MKETAResponse> {
55+
public func cancellableCalculateETA() -> CancellablePromise<MKETAResponse> {
5656
return CancellablePromise(task: MKDirectionsTask(self)) { calculateETA(completionHandler: $0.resolve) }
5757
}
5858
}

Sources/MKMapSnapshotter+Promise.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fileprivate class MKMapSnapshotterTask: CancellableTask {
4242

4343
extension MKMapSnapshotter {
4444
/// Starts generating the snapshot using the options set in this object.
45-
public func startCC() -> CancellablePromise<MKMapSnapshot> {
45+
public func cancellableStart() -> CancellablePromise<MKMapSnapshot> {
4646
return CancellablePromise(task: MKMapSnapshotterTask(self)) { start(completionHandler: $0.resolve) }
4747
}
4848
}

Tests/TestMapKit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension Test_MKDirections_Swift {
7777
let rq = MKDirectionsRequest()
7878
let directions = MockDirections(request: rq)
7979

80-
directions.calculateCC().done { _ in
80+
directions.cancellableCalculate().done { _ in
8181
XCTFail()
8282
}.catch(policy: .allErrors) {
8383
$0.isCancelled ? ex.fulfill() : XCTFail()
@@ -97,7 +97,7 @@ extension Test_MKDirections_Swift {
9797
}
9898

9999
let rq = MKDirectionsRequest()
100-
MockDirections(request: rq).calculateETACC().done { _ in
100+
MockDirections(request: rq).cancellableCalculateETA().done { _ in
101101
XCTFail()
102102
}.catch(policy: .allErrors) {
103103
$0.isCancelled ? ex.fulfill() : XCTFail()
@@ -119,7 +119,7 @@ extension Test_MKSnapshotter_Swift {
119119
}
120120

121121
let snapshotter = MockSnapshotter()
122-
snapshotter.startCC().done { _ in
122+
snapshotter.cancellableStart().done { _ in
123123
XCTFail()
124124
}.catch(policy: .allErrors) {
125125
$0.isCancelled ? ex.fulfill() : XCTFail()

0 commit comments

Comments
 (0)