refactor: inline recordEffectScope
This commit is contained in:
parent
2cc5615590
commit
ef2eaef3aa
|
@ -2,7 +2,7 @@ import { extend, hasChanged } from '@vue/shared'
|
|||
import type { ComputedRefImpl } from './computed'
|
||||
import type { TrackOpTypes, TriggerOpTypes } from './constants'
|
||||
import { type Dep, globalVersion } from './dep'
|
||||
import { recordEffectScope } from './effectScope'
|
||||
import { activeEffectScope } from './effectScope'
|
||||
import { warn } from './warning'
|
||||
|
||||
export type EffectScheduler = (...args: any[]) => any
|
||||
|
@ -137,7 +137,9 @@ export class ReactiveEffect<T = any>
|
|||
onTrigger?: (event: DebuggerEvent) => void
|
||||
|
||||
constructor(public fn: () => T) {
|
||||
recordEffectScope(this)
|
||||
if (activeEffectScope && activeEffectScope.active) {
|
||||
activeEffectScope.effects.push(this)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { ReactiveEffect } from './effect'
|
||||
import { warn } from './warning'
|
||||
|
||||
let activeEffectScope: EffectScope | undefined
|
||||
export let activeEffectScope: EffectScope | undefined
|
||||
|
||||
export class EffectScope {
|
||||
/**
|
||||
|
@ -120,15 +120,6 @@ export function effectScope(detached?: boolean) {
|
|||
return new EffectScope(detached)
|
||||
}
|
||||
|
||||
export function recordEffectScope(
|
||||
effect: ReactiveEffect,
|
||||
scope: EffectScope | undefined = activeEffectScope,
|
||||
) {
|
||||
if (scope && scope.active) {
|
||||
scope.effects.push(effect)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current active effect scope if there is one.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue