-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
feat: add pause/resume
methods for render
function
#9206
Conversation
Size ReportBundles
Usages
|
d536488
to
5a279be
Compare
This looks and sounds promising. Could you maybe elaborate on to what extend this is the same as what @BenceSzalai explained in #5386 (comment). I think this is what he calls 'level 5' right? Also you mentioned in #5386 (comment) that it's more difficult to achieve for |
The reason why v-show cannot be processed is because v-show is the data obtained during the update process. If we pause the execution of the effect, the element will never be re-displayed. |
2bd5dcd
to
9bda252
Compare
For |
pause/resume
function to ReactiveEffect
pause
and resume
methods for render
function
pause
and resume
methods for render
functionpause/resume
methods for render
function
Regarding the Related code:
|
Can someone take a look at this PR? |
This feature allows me to use |
❌ Deploy Preview for vue-sfc-playground failed.
|
@posva Sorry for bothering you, could you take a look at this PR? |
@@ -127,6 +127,8 @@ const KeepAliveImpl: ComponentOptions = { | |||
|
|||
sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => { | |||
const instance = vnode.component! | |||
// on activation, resume the effect of the component instance and immediately execute the call during the pause process | |||
instance.effect.resume(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could have a prop for KeepAlive to toggle this behavior (and default disabling it to keep existing behaviour)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can add a prop to preserve the original behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a lazy
prop to control whether it should pause in the deactivated state.
} else { | ||
return super.run() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the compatibility of pausable effect. Since this is not bound to the runtime/dom, I wonder if this could be generally available in ReactiveEffect
directly.
/cc @yyx990803 WDYT? Or do you think it deserves a dedicated RFC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the addition of pause
and resume
methods in ReactiveEffect
has significant implications for the existing codebase, I have initiated an RFC to discuss this feature.
/cc @yyx990803 @antfu
I have added the |
@Alfred-Skyblue Besides Keep-Alive, I guess this is something that could also be applicable here?: vuejs/rfcs#501 |
@ferferga The functionality has temporarily shifted to be implemented in #9651. I noticed your mention in the RFC that state changes in internal components during the execution of a Transition animation would disrupt the animation state. Regarding the solution you proposed:
Currently, we have implemented detachment for the scope of component instances in the EffectScope. Considering performance reasons, recursively pausing might lead to performance issues due to excessive depth. As of now, the solution I can think of is to manually call |
fixed #5386
To address the issue of
KeepAlive
repeatedly executing theeffect
in thedeactivate
state, I have addedpause
andresume
methods toReactiveEffect
for pausing and resuming the execution of theeffect
. Currently, it is used in theKeepAlive
component. When the component is in thedeactivated
state, it pauses the execution of theeffect
and keeps track of whether it was called during the pause. When the component is in theactivated
state, it resumes the execution of theeffect
and immediately executes it once if therun
function was called during the pause.