Use IAbortable

This commit is contained in:
RMidhunSuresh 2021-11-17 20:27:23 +05:30
parent ea2842f37f
commit 8fcfd713e0
2 changed files with 3 additions and 4 deletions

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
interface IAbortable {
export interface IAbortable {
abort();
}

View File

@ -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<Response>) {
export function abortOnTimeout(createTimeout: TimeoutCreator, timeoutAmount: number, requestResult: IAbortable, responsePromise: Promise<Response>) {
const timeout = createTimeout(timeoutAmount);
// abort request if timeout finishes first
let timedOut = false;