Skip to content

Commit

Permalink
Merge pull request ferdikoomen#1627 from pitmullerIngka/fix/next-prom…
Browse files Browse the repository at this point in the history
…ise-resolve

fix: adjust promise resolve for next issue
  • Loading branch information
ferdikoomen authored Jul 28, 2023
2 parents 1095d07 + 11f84f5 commit beccf2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/templates/core/CancelablePromise.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ export class CancelablePromise<T> implements Promise<T> {
return;
}
this.#isResolved = true;
this.#resolve?.(value);
if (this.#resolve) this.#resolve(value);
};

const onReject = (reason?: any): void => {
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return;
}
this.#isRejected = true;
this.#reject?.(reason);
if (this.#reject) this.#reject(reason);
};

const onCancel = (cancelHandler: () => void): void => {
Expand Down Expand Up @@ -120,7 +120,7 @@ export class CancelablePromise<T> implements Promise<T> {
}
}
this.#cancelHandlers.length = 0;
this.#reject?.(new CancelError('Request aborted'));
if (this.#reject) this.#reject(new CancelError('Request aborted'));
}

public get isCancelled(): boolean {
Expand Down
8 changes: 4 additions & 4 deletions test/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ export class CancelablePromise<T> implements Promise<T> {
return;
}
this.#isResolved = true;
this.#resolve?.(value);
if (this.#resolve) this.#resolve(value);
};

const onReject = (reason?: any): void => {
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return;
}
this.#isRejected = true;
this.#reject?.(reason);
if (this.#reject) this.#reject(reason);
};

const onCancel = (cancelHandler: () => void): void => {
Expand Down Expand Up @@ -3345,15 +3345,15 @@ export class CancelablePromise<T> implements Promise<T> {
return;
}
this.#isResolved = true;
this.#resolve?.(value);
if (this.#resolve) this.#resolve(value);
};

const onReject = (reason?: any): void => {
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return;
}
this.#isRejected = true;
this.#reject?.(reason);
if (this.#reject) this.#reject(reason);
};

const onCancel = (cancelHandler: () => void): void => {
Expand Down

0 comments on commit beccf2d

Please sign in to comment.