Handle nested controlled events#8251
Merged
sebmarkbage merged 1 commit intofacebook:masterfrom Nov 11, 2016
Merged
Conversation
6ac727d to
634ee5d
Compare
sophiebits
approved these changes
Nov 10, 2016
| enqueueStateRestore() { | ||
| needsRestoreState = true; | ||
| enqueueStateRestore(target) { | ||
| if (restoreTarget) { |
Collaborator
There was a problem hiding this comment.
We have accumulateInto, forEachAccumulated if you want.
Contributor
Author
There was a problem hiding this comment.
I find that indirection hard to read and not sure how inlinable that is.
634ee5d to
9c3526c
Compare
I came up with a contrived case of where nested controlled events could fire within the same batch - but on different targets. I think we came to the conclusion that controlled values typically cannot use preventDefault so it is ok that they don't flush until after the event has finished. So therefore we accumulate a queue of all the nested targets within a batch and then restore state on all of them. I'm still skeptical that this is the correct way to do controlled values. The reason we have to do them in a single event loop is because when you type, the sequence of values that get accepted or not can matter. I wonder if there is a scenario we can come up with where you can fire multiple inner events in an event loop and end up with batching causing problems. This effectively just reimplements asap again but with no allocations for a single target and no closure allocations.
9c3526c to
61b3930
Compare
acusti
pushed a commit
to brandcast/react
that referenced
this pull request
Mar 15, 2017
I came up with a contrived case of where nested controlled events could fire within the same batch - but on different targets. I think we came to the conclusion that controlled values typically cannot use preventDefault so it is ok that they don't flush until after the event has finished. So therefore we accumulate a queue of all the nested targets within a batch and then restore state on all of them. I'm still skeptical that this is the correct way to do controlled values. The reason we have to do them in a single event loop is because when you type, the sequence of values that get accepted or not can matter. I wonder if there is a scenario we can come up with where you can fire multiple inner events in an event loop and end up with batching causing problems. This effectively just reimplements asap again but with no allocations for a single target and no closure allocations.
This file contains hidden or 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
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.
I came up with a contrived case of where nested controlled events could fire within the same batch - but on different targets.
I think we came to the conclusion that controlled values typically cannot use preventDefault so it is ok that they don't flush until after the event has finished. So therefore we accumulate a queue of all the nested targets within a batch and then restore state on all of them.
I'm still skeptical that this is the correct way to do controlled values. The reason we have to do them in a single event loop is because when you type, the sequence of values that get accepted or not can matter. I wonder if there is a scenario we can come up with where you can fire multiple
inner events in an event loop and end up with batching causing problems.