diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2020-08-19 14:43:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 14:43:20 +0200 |
commit | 1507a8cf2d8bce8c3596583b995fea4914a99203 (patch) | |
tree | 3e9280b01dab60dcea368894a153a9237884d676 /op_crates/web/lib.deno_web.d.ts | |
parent | 27f4aeb92469660fdd78a89a7b2902c08a23ca4a (diff) |
refactor(op_crates/web): move abort signal (#7117)
Diffstat (limited to 'op_crates/web/lib.deno_web.d.ts')
-rw-r--r-- | op_crates/web/lib.deno_web.d.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/op_crates/web/lib.deno_web.d.ts b/op_crates/web/lib.deno_web.d.ts index b402529e2..d24a3b76f 100644 --- a/op_crates/web/lib.deno_web.d.ts +++ b/op_crates/web/lib.deno_web.d.ts @@ -1,5 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +/* eslint-disable @typescript-eslint/no-explicit-any */ + /// <reference no-default-lib="true" /> /// <reference lib="esnext" /> @@ -185,3 +187,51 @@ declare class TextEncoder { ): { read: number; written: number }; readonly [Symbol.toStringTag]: string; } + +/** 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; +} + +/** 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. */ + readonly aborted: boolean; + onabort: ((this: AbortSignal, ev: Event) => any) | null; + addEventListener<K extends keyof AbortSignalEventMap>( + type: K, + listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, + options?: boolean | AddEventListenerOptions, + ): void; + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions, + ): void; + removeEventListener<K extends keyof AbortSignalEventMap>( + type: K, + listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, + options?: boolean | EventListenerOptions, + ): void; + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions, + ): void; +} + +declare const AbortSignal: { + prototype: AbortSignal; + new (): AbortSignal; +}; |