Cancellable Promises
Example usage
import { createCancellablePromise } from 'csp-coffee/cancellablePromise'
const { cancellablePromise, resolve, reject } = createCancellablePromise(() => {
console.log('Do something when promise is cancelled');
})Cancelling the promise
cancel: (reason?: any) => Promise<void>
import { createCancellablePromise } from 'csp-coffee/cancellablePromise'
const { cancellablePromise, resolve, reject } = createCancellablePromise((message: string) => {
console.log(message);
});
cancellablePromise.cancel('I AM CANCELLED')
// Will log 'I AM CANCELLED' to the consoleLast updated