Skip to content

Commit

Permalink
Merge pull request #243 from chriskrycho/finally
Browse files Browse the repository at this point in the history
Use `finally` for `waiter.endAsync`
  • Loading branch information
chriskrycho authored Feb 24, 2022
2 parents 1040885 + 0576031 commit 3f1610e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions addon/tracked-async-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ class _TrackedAsyncData<T> {

// Otherwise, we know that haven't yet handled that promise anywhere in the
// system, so we continue creating a new instance.
promise.then(
(value) => {
this.#state.data = ["RESOLVED", value];
promise
.then(
(value) => (this.#state.data = ["RESOLVED", value]),
(error) => (this.#state.data = ["REJECTED", error])
)
.finally(() => {
waiter.endAsync(this.#token);
},
(error) => {
this.#state.data = ["REJECTED", error];
waiter.endAsync(this.#token);
}
);
});

TRACKED_PROMISES.set(promise, this);

Expand Down

0 comments on commit 3f1610e

Please sign in to comment.