From 8fcfd713e07e8a04f4f2f39abf056cf45da9298f Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 17 Nov 2021 20:27:23 +0530 Subject: [PATCH] Use IAbortable --- src/utils/AbortableOperation.ts | 2 +- src/utils/timeout.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/utils/AbortableOperation.ts b/src/utils/AbortableOperation.ts index 0cc49e10..d03f820a 100644 --- a/src/utils/AbortableOperation.ts +++ b/src/utils/AbortableOperation.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -interface IAbortable { +export interface IAbortable { abort(); } diff --git a/src/utils/timeout.ts b/src/utils/timeout.ts index 96efc10d..f0460047 100644 --- a/src/utils/timeout.ts +++ b/src/utils/timeout.ts @@ -17,12 +17,11 @@ limitations under the License. import {ConnectionError} from "../matrix/error.js"; import type {Timeout} from "../platform/web/dom/Clock.js" +import type {IAbortable} from "./AbortableOperation"; 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: TimeoutCreator, timeoutAmount: number, requestResult: Abortable, responsePromise: Promise) { +export function abortOnTimeout(createTimeout: TimeoutCreator, timeoutAmount: number, requestResult: IAbortable, responsePromise: Promise) { const timeout = createTimeout(timeoutAmount); // abort request if timeout finishes first let timedOut = false;