core icon indicating copy to clipboard operation
core copied to clipboard

feat(reactivity): add `pause/resume` methods to `ReactiveEffect`

Open Alfred-Skyblue opened this issue 1 year ago • 8 comments

RFC: https://github.com/vuejs/rfcs/discussions/599

In this PR, a pause/resume method has been added to the effect to control whether the effect can be executed. When the effect is in a paused state and the run method is called, it will save the call once, and it can be immediately executed after calling the resume method. This is used in certain situations to improve performance by reducing unnecessary execution of effects, such as pausing in the deactivated state of the keep-alive component, or implementing lazy updates in conjunction with IntersectionObserver.

In #9206, derived classes were added for extension, aimed at controlling the pause/resume of the render function. Following @antfu's suggestion, the pause and resume methods were added to the ReactiveEffect class. As the ReactiveEffect class has a widespread impact, a new PR has been opened.

Alfred-Skyblue avatar Nov 21 '23 11:11 Alfred-Skyblue