Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancellation support #15

Merged
merged 6 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface XHROptions {
data?: string;
strictSSL?: boolean;
followRedirects?: number;
token?: CancellationToken;
agent?: HttpProxyAgent | HttpsProxyAgent;
}

Expand All @@ -30,6 +31,41 @@ export interface XHRConfigure {
(proxyUrl: string | undefined, strictSSL: boolean): void;
}

export interface Disposable {
/**
* Dispose this object.
*/
dispose(): void;
}
/**
* Represents a typed event.
*/
export interface Event<T> {
/**
*
* @param listener The listener function will be call when the event happens.
* @param thisArgs The 'this' which will be used when calling the event listener.
* @param disposables An array to which a {{IDisposable}} will be added. The
* @return
*/
(listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
}
/**
* Defines a CancellationToken. This interface is not
* intended to be implemented. A CancellationToken must
* be created via a CancellationTokenSource.
*/
export interface CancellationToken {
/**
* Is `true` when the token has been cancelled, `false` otherwise.
*/
readonly isCancellationRequested: boolean;
/**
* An [event](#Event) which fires upon cancellation.
*/
readonly onCancellationRequested: Event<any>;
}

export type HttpProxyAgent = import('http-proxy-agent').HttpProxyAgent;

export type HttpsProxyAgent = import('https-proxy-agent').HttpsProxyAgent;
Expand All @@ -39,4 +75,4 @@ export type Headers = { [header: string]: string | string[] | undefined };
export declare const configure: XHRConfigure;
export declare const xhr: XHRRequest;

export declare function getErrorStatusDescription(status: number): string;
export declare function getErrorStatusDescription(status: number): string;
Loading