-
-
Notifications
You must be signed in to change notification settings - Fork 106
feat: renderWatch / renderEffect #86
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
Merged
Merged
Conversation
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
Size ReportBundles
Usages
|
0d2b476
to
41ddba4
Compare
This was referenced Jan 5, 2024
sxzz
approved these changes
Jan 6, 2024
This was referenced Jan 7, 2024
Closed
9 tasks
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.
The origin of this API
The introduction of a specific Render Watch API is primarily due to these reasons:
The Flush mode of the Watch API doesn't satisfy the requirements for rendering scenarios. Initially, in PR feat(runtime-vapor):
watchEffect
/watch
andonEffectCleanup
#69, we used a method that determined ifwatchEffect
was within the render function and treated it uniquely. However, after discussions with Evan You, he proposed using an independent Render Watch API to accomplish this feature.Implementation of Life Cycle Hooks in Vapor mode: The BeforeUpdate and Updated hooks are intimately connected to re-runs of the render function. But in Vapor mode, the render function only runs once during a component's lifecycle. Updating content is divided among each effect; thus implementing BeforeUpdate and Updated hooks requires emitting events when an effect related to rendering is activated. Introducing a separate Render Watch API facilitates internal implementation of these hooks.
The Render Watch API is exclusively used within the render function and generated by the Compiler - unlike the regular Watch API which needs consideration for Developer Experience (DX). By isolating it into its own standalone API simplifies most implementations while adding features specifically tailored for rendering scenarios.
Some envisioned use cases