if (!effectStack.includes(effect)) {
cleanup(effect)
try {
+ enableTracking()
effectStack.push(effect)
activeEffect = effect
return fn(...args)
} finally {
effectStack.pop()
+ resetTracking()
activeEffect = effectStack[effectStack.length - 1]
}
}
}
let shouldTrack = true
+const trackStack: boolean[] = []
export function pauseTracking() {
+ trackStack.push(shouldTrack)
shouldTrack = false
}
-export function resumeTracking() {
+export function enableTracking() {
+ trackStack.push(shouldTrack)
shouldTrack = true
}
+export function resetTracking() {
+ const last = trackStack.pop()
+ shouldTrack = last === undefined ? true : last
+}
+
export function track(target: object, type: TrackOpTypes, key: unknown) {
if (!shouldTrack || activeEffect === undefined) {
return
export {
effect,
stop,
+ trigger,
+ track,
+ enableTracking,
pauseTracking,
- resumeTracking,
+ resetTracking,
ITERATE_KEY,
ReactiveEffect,
ReactiveEffectOptions,
import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
import { warn } from './warning'
import { capitalize } from '@vue/shared'
-import { pauseTracking, resumeTracking, DebuggerEvent } from '@vue/reactivity'
+import { pauseTracking, resetTracking, DebuggerEvent } from '@vue/reactivity'
export { onActivated, onDeactivated } from './components/KeepAlive'
setCurrentInstance(target)
const res = callWithAsyncErrorHandling(hook, target, type, args)
setCurrentInstance(null)
- resumeTracking()
+ resetTracking()
return res
})
if (prepend) {
import { VNode, VNodeChild, isVNode } from './vnode'
-import { ReactiveEffect, shallowReadonly } from '@vue/reactivity'
+import {
+ ReactiveEffect,
+ shallowReadonly,
+ pauseTracking,
+ resetTracking
+} from '@vue/reactivity'
import {
PublicInstanceProxyHandlers,
ComponentPublicInstance,
currentInstance = instance
currentSuspense = parentSuspense
+ pauseTracking()
const setupResult = callWithErrorHandling(
setup,
instance,
ErrorCodes.SETUP_FUNCTION,
[propsProxy, setupContext]
)
+ resetTracking()
currentInstance = null
currentSuspense = null
import { VNode } from './vnode'
import { Data, ComponentInternalInstance, Component } from './component'
import { isString, isFunction } from '@vue/shared'
-import { toRaw, isRef, pauseTracking, resumeTracking } from '@vue/reactivity'
+import { toRaw, isRef, pauseTracking, resetTracking } from '@vue/reactivity'
import { callWithErrorHandling, ErrorCodes } from './errorHandling'
type ComponentVNode = VNode & {
console.warn(...warnArgs)
}
- resumeTracking()
+ resetTracking()
}
function getComponentTrace(): ComponentTraceStack {