@salesforce/apex-node
Version:
Salesforce JS library for Apex
32 lines • 1.14 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
* See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CancellationTokenSource = void 0;
class Token {
isCancellationRequested = false;
callbacks = [];
onCancellationRequested(listener) {
if (this.isCancellationRequested) {
listener();
}
else {
this.callbacks.push(listener);
}
}
}
class CancellationTokenSource {
token = new Token();
async asyncCancel() {
this.token.isCancellationRequested = true;
for (const callback of this.token.callbacks) {
await callback();
}
this.token.callbacks = [];
}
}
exports.CancellationTokenSource = CancellationTokenSource;
//# sourceMappingURL=cancellation.js.map