mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
Add support for AbortController/AbortSignal (#4757)
This commit is contained in:
parent
95eb6d780c
commit
cb64cf3ce2
6 changed files with 154 additions and 4 deletions
16
cli/js/lib.deno.shared_globals.d.ts
vendored
16
cli/js/lib.deno.shared_globals.d.ts
vendored
|
@ -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>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue