Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Suspend event listeners during reconciliation? #71

Closed
LPGhatguy opened this issue Apr 21, 2018 · 2 comments
Closed

Suspend event listeners during reconciliation? #71

LPGhatguy opened this issue Apr 21, 2018 · 2 comments
Labels
feature: idea Proposed feature, but not on the roadmap.

Comments

@LPGhatguy
Copy link
Contributor

A common source of bugs in Roact code that I've seen involves hooking into Changed or using GetPropertyChangedSignal, and calling setState in response.

This pattern is perfectly fine as long as the reconciler doesn't affect the properties you're listening to synchronously. I use this technique in my Roact Windowing example to make the windowing responsive to your current scroll position.

One idea that @AmaranthineCodices had would be to suspend those events while the reconciler is running, eliminating that entire class of bugs.

Are there any cases where you'd want these events? It's only problematic when you end up calling setState directly or indirectly.

@LPGhatguy LPGhatguy added the feature: idea Proposed feature, but not on the roadmap. label Apr 21, 2018
@LPGhatguy
Copy link
Contributor Author

There is a bit of precedence for this in certain contexts -- React defers re-rendering when setState is called inside one of the brower's (synchronous) event handlers.

It's possible that we should do the same thing for events! I imagine this would prevent a lot of bugs, too!

@ZoteTheMighty
Copy link
Contributor

This was implemented in #48!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature: idea Proposed feature, but not on the roadmap.
Projects
None yet
Development

No branches or pull requests

2 participants