Skip to content

Commit

Permalink
use weaker-event definition for cancellation token, #81574
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Feb 11, 2020
1 parent f4a868f commit 1c4f0dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/vs/base/common/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ import { Emitter, Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';

export interface CancellationToken {

/**
* A flag signalling is cancellation has been requested.
*/
readonly isCancellationRequested: boolean;

/**
* An event emitted when cancellation is requested
* An event which fires when cancellation is requested.
*
* @event
*/
readonly onCancellationRequested: Event<any>;
readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable;
}

const shortcutEvent = Object.freeze(function (callback, context?): IDisposable {
const shortcutEvent: Event<any> = Object.freeze(function (callback, context?): IDisposable {
const handle = setTimeout(callback.bind(context), 0);
return { dispose() { clearTimeout(handle); } };
} as Event<any>);
});

export namespace CancellationToken {

Expand Down
8 changes: 6 additions & 2 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ declare namespace monaco {
}

export interface CancellationToken {
/**
* A flag signalling is cancellation has been requested.
*/
readonly isCancellationRequested: boolean;
/**
* An event emitted when cancellation is requested
* An event which fires when cancellation is requested.
*
* @event
*/
readonly onCancellationRequested: IEvent<any>;
readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable;
}
/**
* Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986.
Expand Down

0 comments on commit 1c4f0dd

Please sign in to comment.