Add support for AbortController/AbortSignal (#4757)

This commit is contained in:
Kitson Kelly 2020-04-16 00:10:49 +10:00 committed by GitHub
parent 95eb6d780c
commit cb64cf3ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 154 additions and 4 deletions

View file

@ -1256,6 +1256,16 @@ declare class CustomEvent<T = any> extends Event {
readonly detail: T;
}
/** A controller object that allows you to abort one or more DOM requests as and
* when desired. */
declare class AbortController {
/** Returns the AbortSignal object associated with this object. */
readonly signal: AbortSignal;
/** Invoking this method will set this object's AbortSignal's aborted flag and
* signal to any observers that the associated activity is to be aborted. */
abort(): void;
}
interface AbortSignalEventMap {
abort: Event;
}
@ -1263,10 +1273,8 @@ interface AbortSignalEventMap {
/** A signal object that allows you to communicate with a DOM request (such as a
* Fetch) and abort it if required via an AbortController object. */
interface AbortSignal extends EventTarget {
/**
* Returns true if this AbortSignal's AbortController has signaled to abort,
* and false otherwise.
*/
/** Returns true if this AbortSignal's AbortController has signaled to abort,
* and false otherwise. */
readonly aborted: boolean;
onabort: ((this: AbortSignal, ev: Event) => any) | null;
addEventListener<K extends keyof AbortSignalEventMap>(