UNPKG

1.03 kBTypeScriptView Raw
1import { Event } from './events';
2import { Disposable } from './disposable';
3/**
4 * Defines a CancellationToken. This interface is not
5 * intended to be implemented. A CancellationToken must
6 * be created via a CancellationTokenSource.
7 */
8export interface CancellationToken {
9 /**
10 * Is `true` when the token has been cancelled, `false` otherwise.
11 */
12 readonly isCancellationRequested: boolean;
13 /**
14 * An {@link Event event} which fires upon cancellation.
15 */
16 readonly onCancellationRequested: Event<any>;
17}
18export declare namespace CancellationToken {
19 const None: CancellationToken;
20 const Cancelled: CancellationToken;
21 function is(value: any): value is CancellationToken;
22}
23export interface AbstractCancellationTokenSource extends Disposable {
24 token: CancellationToken;
25 cancel(): void;
26}
27export declare class CancellationTokenSource implements AbstractCancellationTokenSource {
28 private _token;
29 get token(): CancellationToken;
30 cancel(): void;
31 dispose(): void;
32}