@openpass/openpass-js-sdk
Version:
OpenPass SSO JavaScript SDK
16 lines • 633 B
JavaScript
export default class AbortablePromise extends Promise {
constructor(executor) {
//temporary variable to get access to the abortCallback
let onAbort = undefined;
// call the promise constructor to get access to the abortCallback handler and assign it to the onAbort variable
super((rs, rj) => executor(rs, rj, (abortCallback) => (onAbort = abortCallback)));
this.onAbort = onAbort;
}
// call this method to invoke the onAbort function of the promise
abort() {
if (this.onAbort) {
this.onAbort();
}
}
}
//# sourceMappingURL=abortablePromise.js.map