This repository was archived by the owner on Jul 19, 2025. It is now read-only.
feat: renderWatch / renderEffect #86
Merged
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