-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: wait a microtask for await blocks to reduce UI churn #11989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 99dcc68 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Are you sure this works? I still get the pending block logged in this example |
This PR aims to reduce the amount of churn on pending blocks. The |
The referenced issue states:
... which is what is still happening here. Switching from one resolved promise to another is the main thing that people complain about. |
I've updated the PR to reflect that this isn't solving that issue anymore. |
But what is this PR really changing then? The pending block is still rendered on promise change, just the effect isn't fired because it's cleaned up before it can run. |
@dummdidumm The pending block isn't rendered on promise change if it only takes a microtask (except initial mount). There was a bug in your case, but I just fixed that. |
packages/svelte/tests/runtime-runes/samples/await-resolve/main.svelte
Outdated
Show resolved
Hide resolved
With your change the referenced issue is fixed, and my playground works as expected. I assume this was a "order in the task queue" issue and adding the |
Why render the pending block on mount, if the promise is already resolved? Opened #11995 as a proof of concept of not doing that |
Converted this to a draft. I think I can get then blocks to also not remount too. Update: ready now! |
The pending block is destroyed and recreated if you go from one unresolved promise to another. Working on it locally |
…1989) * fix: wait a microtask for await blocks to reduce UI churn * fix: wait a microtask for await blocks to reduce UI churn * fix: wait a microtask for await blocks to reduce UI churn * fix bug * Make then blocks reactive * add test * update test * update test * Update packages/svelte/src/internal/client/dom/blocks/await.js Co-authored-by: Simon H <[email protected]> * Add support for catch block * slightly more specific naming * if we use the reserved $$ prefix we dont need to mess around with scope.generate * omit args for then/catch if unnecessary * neaten up some old code * shrink code * simplify test * add failing test * preserve pending blocks * update test * fix comment typo * tidy up --------- Co-authored-by: Simon H <[email protected]> Co-authored-by: Rich Harris <[email protected]>
The PR changes await blocks, to avoid showing/hiding the pending/then state of an each block if the promise resolves by the next microtask. Fixes #8459.