-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[Flare] Rework the responder dispatching/batching mechanism #16334
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Details of bundled changes.Comparing: e89c19d...f7375c5 react-dom
react-events
react-native-renderer
Generated by 🚫 dangerJS |
@necolas @acdlite @sebmarkbage Would be good to get a review on this PR when you folks have a chance. |
necolas
approved these changes
Aug 19, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We want to change the event system so it is possible to handle and manage ownership/propagation of event responders as we process the fiber tree. In order to do this, we need to change how the current event responder system works so that events that are queued to dispatch happen after the processing of each individual responder, rather than at the end.
Previously, we built up an array of all user events that needed to be dispatched, along with their priority and dispatched them all together. This made it impossible for user events to have effects that make it possible to control propagation and ownership though, as by this stage, we've already processed the responders. To illustrate this:
Old Model:
If a native event happens and Responder C gets activated, we then bubble to Responder B and then to Responder A. Along the way, each responder might
dispatchEvent
, so we'd store the user events in an array. Once all Responders A, B, C have been handled we then flush all the events we've collected.New Model:
If a native event happens and Responder C gets activated, we then bubble to Responder B and then to Responder A. Along the way, each responder might
dispatchEvent
, if so, we now dispatch the user events at that point, rather than having to queue them up to flush at the end. We are able to do this by wrapping the entire event process inbatchedEventUpdates
and having a dedicated event that sets a flag for when we're in the process of executing a user event. The priority logic from before remains unchanged because of these tweaks.I also removed the global ownership model, as this new mechanism allows for a much more refined approach that simply globally saying a responder is the only owner. It also conflicts with how this new mechanism works.