Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
I suspected our flushing logic was unnecessarily baroque, and on closer inspection it looks like we can simplify it quite a bit. This PR does so: it gets rid of the
scheduler_mode
stuff in favour of just flushing the root effect queue until it's empty. This means a) we don't need to mess around with microtasks (theoretically this will improve performance for updates that spawn further updates, though it's unlikely to be measurable) and b) we don't need to do any book-keeping to prevent infinite loops — we just... put everything in a loop.We can also get rid of the
process_deferred
middleman, and lose a now-unnecessary try-finally block.Due to the vagaries of the
Animation
shim we use in the test suite, this does necessitate a couple of harmless edits to a handful of tests.I also noticed that the inline docs for both
flush_sync
and its public counterpartflushSync
are out of date or wrong. We don't need the indirection (it was necessary at one point, long ago, whenflush_sync
took aflush_previous
argument, but no longer) so we now just expose the internal function directly. While I was at it I fixed the types — the return value offlushSync
now correctly matches the return value of its callback, if provided.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint