Skip to content

Commit

Permalink
fix(utils): make 'unwrap' update immediate after resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
organize committed Nov 7, 2024
1 parent ed87699 commit 2c1bc0a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/vanilla/utils/unwrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ export function unwrap<Value, Args extends unknown[], Result, PendingValue>(
return { v: promise as Awaited<Value> }
}
if (promise !== prev?.p) {
promise
.then(
(v) => {
promiseResultCache.set(promise, v as Awaited<Value>)
setSelf()
},
(e) => {
promiseErrorCache.set(promise, e)
setSelf()
}
)
promise.then(
(v) => {
promiseResultCache.set(promise, v as Awaited<Value>)
setSelf()
},
(e) => {
promiseErrorCache.set(promise, e)
setSelf()
},
)
}
if (promiseErrorCache.has(promise)) {
throw promiseErrorCache.get(promise)
Expand Down

0 comments on commit 2c1bc0a

Please sign in to comment.