[Flight] Lazily parse models and allow any value to suspend#18476
Merged
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f332493:
|
8a75c38 to
38590c5
Compare
Details of bundled changes.Comparing: 59fd09c...f332493 react-flight-dom-webpack
react-flight-dom-relay
react-server
react-client
Size changes (stable) |
Details of bundled changes.Comparing: 59fd09c...f332493 react-flight-dom-webpack
react-flight-dom-relay
react-server
react-client
Size changes (experimental) |
devknoll
reviewed
Apr 3, 2020
gaearon
approved these changes
Apr 3, 2020
This ensures that we don't spend CPU cycles processing models that we're not going to end up rendering. This model will also allow us to suspend during this initialization if data is not yet available to satisfy the model.
The root model needs to be cast at one point or another same as othe chunks. So we can parameterize the read instead of the whole Response.
The special case to read the root isn't worth the field and code.
Instead of storing it on the data tuple which is kind of dynamic, we store it on each Chunk. This uses more memory. Especially compared to just making initializeBlock a closure, but overall is simpler.
Response objects are exposed.
This allows us to stream in server components one after another over the wire. It also allows parallelizing their fetches and resuming only the server component instead of the whole parent block. This doesn't yet allow us to suspend deeper while waiting on this content because we don't have "lazy elements".
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.
There's a bunch of refactoring here but there are two key features that this unlocks: