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
onTrigger?: (event: DebuggerEvent) => void
constructor(public fn: () => T) {
- recordEffectScope(this)
+ if (activeEffectScope && activeEffectScope.active) {
+ activeEffectScope.effects.push(this)
+ }
}
/**
import type { ReactiveEffect } from './effect'
import { warn } from './warning'
-let activeEffectScope: EffectScope | undefined
+export let activeEffectScope: EffectScope | undefined
export class EffectScope {
/**
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.
*