mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Use IAbortable
This commit is contained in:
parent
ea2842f37f
commit
8fcfd713e0
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
interface IAbortable {
|
||||
export interface IAbortable {
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user