mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Convert timeout.js to ts
This commit is contained in:
parent
8a169d5ddc
commit
afecac3e3c
@ -19,7 +19,7 @@ import {
|
||||
AbortError,
|
||||
ConnectionError
|
||||
} from "../../../../matrix/error.js";
|
||||
import {abortOnTimeout} from "../../../../utils/timeout.js";
|
||||
import {abortOnTimeout} from "../../../../utils/timeout";
|
||||
import {addCacheBuster} from "./common.js";
|
||||
import {xhrRequest} from "./xhr.js";
|
||||
|
||||
|
@ -16,9 +16,13 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import {ConnectionError} from "../matrix/error.js";
|
||||
import type {Timeout} from "../platform/web/dom/Clock.js"
|
||||
|
||||
type TimeoutCreator = (ms: number) => Timeout;
|
||||
// ts-todo: export type RequestResult from fetch.js? we'll need to wait until it's typescript though.
|
||||
type Abortable = { abort(): void; [key: string]: any };
|
||||
|
||||
export function abortOnTimeout(createTimeout, timeoutAmount, requestResult, responsePromise) {
|
||||
export function abortOnTimeout(createTimeout: TimeoutCreator, timeoutAmount: number, requestResult: Abortable, responsePromise: Promise<Response>) {
|
||||
const timeout = createTimeout(timeoutAmount);
|
||||
// abort request if timeout finishes first
|
||||
let timedOut = false;
|
Loading…
Reference in New Issue
Block a user