Skip to content

Commit

Permalink
Merge pull request #688 from mainmatter/pichfl/refactor-6
Browse files Browse the repository at this point in the history
Prefer "happy path" code style for `_resolve()`
  • Loading branch information
pichfl authored Oct 14, 2022
2 parents 4ccf802 + fd3e6de commit 12a82e7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions addon/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ export default class Modal {
}

_resolve(result) {
if (!this._deferredOutAnimation) {
set(this, '_deferredOutAnimation', defer());
if (this._options.onAnimationModalOutEnd) {
this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});
}

this._result = result;
this._deferred.resolve(result);
if (this._deferredOutAnimation) {
return;
}

waitForPromise(this._deferredOutAnimation.promise);
set(this, '_deferredOutAnimation', defer());
if (this._options.onAnimationModalOutEnd) {
this._deferredOutAnimation.promise.then(() => this._options.onAnimationModalOutEnd()).catch(() => {});
}

this._result = result;
this._deferred.resolve(result);

waitForPromise(this._deferredOutAnimation.promise);
}

_remove() {
Expand Down

0 comments on commit 12a82e7

Please sign in to comment.