-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add flushSync option to update() #3119
Conversation
I don't think we want to call it |
Thought react uses flushSync, but discrete sounds good too |
@trueadm Another option I had in mind is to add |
That's true, I guess I meant as the underlying terminology. I'm just worried everyone will do this rather than use async updates. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Gets complicated with nested updates though and what should happen when others happen etc. |
Another alternative would be to have it in a headless mode as a default (so far it's the main usecase), since there's no benefit from batching as there's no dom reconciliation. Then can just rely on _headless flag. Although it adds implicit inconsistency between .update calls & updated state availability right after it |
Would this really be a problem? You'd have to go looking for this API and then maybe we could ameliorate the problem with some documentation around valid use cases for it. |
Lexical used to have a flush sync flag, we actually killed it. Everyone used that in their tests and then their production surfaces were in async causing a different behavior. |
With that I don't like neither of solutions anymore :) But using internal _flushSync flag is even more confusing, so I'll move on with |
13a45b1
to
d1574fc
Compare
* Add flushSync option to update() * Rename flushSync->discrete
* Add flushSync option to update() * Rename flushSync->discrete
This would allow synchronous updates (e.g. for tests and some cases of headless mode):