You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constexampleOfAsyncFunction=(ms: number)=>newPromise<number>(t=>setTimeout(()=>t(ms),ms));asyncfunctionComp(){constfirst=awaitexampleOfAsyncFunction(1000);// stuff 1...constsecond=awaitexampleOfAsyncFunction(2000);// stuff 2...console.log(getOwner());// → nullreturn<>{/* Calls `toString()` in order to make the compiler wrap the values in `createMemo()` */}{first.toString(16)} - {second.toString(16)}</>}
because after the first await the Owner and contexts would be lost, effects wouldn't be disposed and the component should be wrapped in a createResource() when used
Solution
Couldn't it be possible to get the compiler to manually restore the state after each await?
The output would go from this
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Problem
We currently can't create a component like this
because after the first
await
theOwner
and contexts would be lost, effects wouldn't be disposed and the component should be wrapped in acreateResource()
when usedSolution
Couldn't it be possible to get the compiler to manually restore the state after each
await
?The output would go from this
to this
Beta Was this translation helpful? Give feedback.
All reactions