[RFC] Add pause/resume
function to ReactiveEffect
#599
Alfred-Skyblue
started this conversation in
RFC Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Start Date: 2023-11-14
Target Major Version: 3.x
Implementation PR: vuejs/core#9651
Summary
The proposal recommends adding
pause/resume
methods toRenderEffect
for controlling the pause and resume of effects.pause
method is used to pause the execution of aReactiveEffect
.resume
method is used to resume the execution of aReactiveEffect
.EffectScope
has been extended withpause
andresume
methods, which can be used to pause/resume the execution of allReactiveEffects
within theEffectScope
.Add theUsers have the autonomy to control the invocation of pause/resume actions during the keep-alive lifecycle.lazy
attribute tokeep-alive
so that, during theactivated
anddeactivated
phases, you can control the pause and resume of theEffectScope
for the component instance.Motivation
When the
keep-alive
is in adeactivated
state, if theeffect
within the component depends on an external reactive variable, unnecessary updates occur when this variable is updated. In this RFC, we address this issue by pausing theeffect
to prevent these unnecessary updates.relate: vuejs/core#5386
Basic example
Detailed design
pause
method is used to pause the execution of aReactiveEffect
. If an effect is triggered during the pause process, the effect will be placed into thepausedQueueEffects
.resume
method is used to resume the execution of aReactiveEffect
. This method takes aboolean
parameter. If theresume
method is called withtrue
, and the currenteffect
exists inpausedQueueEffects
, immediately trigger theeffect
once.Unresolved questions
watch
similar to that of a counter, it may result in counting errors.Welcome to discuss.
Beta Was this translation helpful? Give feedback.
All reactions