- Updated formatting of cancelable promise

This commit is contained in:
Ferdi Koomen 2021-10-19 21:56:48 +02:00
parent 6b7efd1523
commit 1a777738f8
2 changed files with 21 additions and 15 deletions

View File

@ -10,10 +10,12 @@ export class CancelablePromise<T> implements Promise<T> {
#resolve?: (value: T | PromiseLike<T>) => void;
#reject?: (reason?: any) => void;
constructor(executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void) => void,
constructor(
executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void
) => void
) {
this.#isPending = true;
this.#isCanceled = false;
@ -69,7 +71,7 @@ export class CancelablePromise<T> implements Promise<T> {
for (const cancelHandler of this.#cancelHandlers) {
cancelHandler();
}
} catch (error) {
} catch(error) {
this.#reject?.(error);
return;
}

View File

@ -68,10 +68,12 @@ export class CancelablePromise<T> implements Promise<T> {
#resolve?: (value: T | PromiseLike<T>) => void;
#reject?: (reason?: any) => void;
constructor(executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void) => void,
constructor(
executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void
) => void
) {
this.#isPending = true;
this.#isCanceled = false;
@ -127,7 +129,7 @@ export class CancelablePromise<T> implements Promise<T> {
for (const cancelHandler of this.#cancelHandlers) {
cancelHandler();
}
} catch (error) {
} catch(error) {
this.#reject?.(error);
return;
}
@ -2537,10 +2539,12 @@ export class CancelablePromise<T> implements Promise<T> {
#resolve?: (value: T | PromiseLike<T>) => void;
#reject?: (reason?: any) => void;
constructor(executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void) => void,
constructor(
executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
onCancel: (cancelHandler: () => void) => void
) => void
) {
this.#isPending = true;
this.#isCanceled = false;
@ -2596,7 +2600,7 @@ export class CancelablePromise<T> implements Promise<T> {
for (const cancelHandler of this.#cancelHandlers) {
cancelHandler();
}
} catch (error) {
} catch(error) {
this.#reject?.(error);
return;
}