MCPcopy
hub / github.com/vuejs/core / run

Method run

packages/reactivity/src/effect.ts:162–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160 }
161
162 run(): T {
163 // TODO cleanupEffect
164
165 if (!(this.flags & EffectFlags.ACTIVE)) {
166 // stopped during cleanup
167 return this.fn()
168 }
169
170 this.flags |= EffectFlags.RUNNING
171 cleanupEffect(this)
172 prepareDeps(this)
173 const prevEffect = activeSub
174 const prevShouldTrack = shouldTrack
175 activeSub = this
176 shouldTrack = true
177
178 try {
179 return this.fn()
180 } finally {
181 if (__DEV__ && activeSub !== this) {
182 warn(
183 'Active effect was not restored correctly - ' +
184 'this is likely a Vue internal bug.',
185 )
186 }
187 cleanupDeps(this)
188 activeSub = prevEffect
189 shouldTrack = prevShouldTrack
190 this.flags &= ~EffectFlags.RUNNING
191 }
192 }
193
194 stop(): void {
195 if (this.flags & EffectFlags.ACTIVE) {

Callers 10

runIfDirtyMethod · 0.95
effectFunction · 0.95
jobFunction · 0.45
watchFunction · 0.45
handleBeginFunction · 0.45
watch.spec.tsFile · 0.45
setupFunction · 0.45
apiWatch.spec.tsFile · 0.45
setupFunction · 0.45

Calls 4

warnFunction · 0.90
cleanupEffectFunction · 0.85
prepareDepsFunction · 0.85
cleanupDepsFunction · 0.85

Tested by 3

handleBeginFunction · 0.36
setupFunction · 0.36
setupFunction · 0.36