Skip to content

Conversation

@dummdidumm
Copy link
Member

Add a new option to the legacy class component interface so that flush_sync can be omitted. Part of sveltejs/kit#12248

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Add a new option to the legacy class component interface so that `flush_sync` can be omitted. Part of sveltejs/kit#12248
@changeset-bot
Copy link

changeset-bot bot commented Aug 22, 2024

🦋 Changeset detected

Latest commit: 461b506

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@trueadm
Copy link
Contributor

trueadm commented Aug 24, 2024

Couldn't we just tell people to use flushSync after? Does that work?

@dummdidumm
Copy link
Member Author

No, it would be a needless potentially hard to detect breaking change. The default for legacy should stay sync

@l1bbcsg
Copy link

l1bbcsg commented Mar 10, 2025

Is this actually implemented correctly?

Comment says flushSync should not run if user opted out, but then the code actually runs it precisely when it was set to false. And setting it to true passes the control to $$host check. Furthermore, default value is undefined which is not === false.

It's simply not possible to control flushSync with sync option, this seems like a typo.
Shouldn't the predicate be like this? Note the extra parenthesis.

if (!(options?.props?.$$host || options.sync === false)) { 
  flushSync();
}

Or, easier to read:

if (!options?.props?.$$host && options.sync !== false) { 
  flushSync();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants