<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "CKToolJS",
  "identifier" : "/documentation/CKToolJS/CancellablePromise",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "CKTool JS"
    ],
    "preciseIdentifier" : "cl/CancellablePromise"
  },
  "title" : "CancellablePromise"
}
-->

# CancellablePromise

A promise that has a function to cancel its operation.

```
interface CancellablePromise
```

## Overview

This class wraps an ordinary promise, but also provides a method that can be used to cancel the promise. The `cancel` function throws `CancelledError` if called.

API object methods return a promise of this type. For example, `PromisesApi` has a `createRecord` method that returns a `CancellablePromise`.

## Topics

### Initializers

[`new inner(
	Promise inner,
	Function? cancel
);`](/documentation/CKToolJS/CancellablePromise/CancellablePromise)

### Instance Properties

[`attribute Promise inner;`](/documentation/CKToolJS/CancellablePromise/inner)

The wrapped promise.

### Instance Methods

[`void cancel();`](/documentation/CKToolJS/CancellablePromise/cancel)

Stops any work the promise is doing.

[`CancellablePromise catch(
	Function? onrejected
);`](/documentation/CKToolJS/CancellablePromise/catch)

Tells `CancellablePromise` what callback to call on failure of the inner promise.

[`CancellablePromise finally(
	Function? onfinally
);`](/documentation/CKToolJS/CancellablePromise/finally)

Tells `CancellablePromise` what callback to call when the inner promise either succeeds or fails.

[`CancellablePromise then(
	Function? onrejected,
	Function? onfullfilled
);`](/documentation/CKToolJS/CancellablePromise/then)

Tells `CancellablePromise` what callbacks to call on success or failure of the inner promise.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)