|
|
|
@ -35,7 +35,7 @@ export default class AbortablePromise<T> implements Promise<T | null> {
|
|
|
|
|
on_abort?: () => Promise<unknown> | void
|
|
|
|
|
): Promise<L | null> {
|
|
|
|
|
console.log("await_or_abort", promise);
|
|
|
|
|
if (promise instanceof AbortablePromise && !on_abort) {
|
|
|
|
|
if (AbortablePromise.isAbortable(promise) && !on_abort) {
|
|
|
|
|
on_abort = async () => promise.abort();
|
|
|
|
|
}
|
|
|
|
|
if (on_abort === undefined) {
|
|
|
|
@ -82,6 +82,10 @@ export default class AbortablePromise<T> implements Promise<T | null> {
|
|
|
|
|
this.emitter = emitter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static isAbortable(o: unknown): o is AbortablePromise<unknown> {
|
|
|
|
|
return (o as { abort: boolean }).abort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abort() {
|
|
|
|
|
this.emitter.abort();
|
|
|
|
|
}
|
|
|
|
|