File tree Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { extend, hasChanged } from '@vue/shared'
2
2
import type { ComputedRefImpl } from './computed'
3
3
import type { TrackOpTypes , TriggerOpTypes } from './constants'
4
4
import { type Dep , globalVersion } from './dep'
5
- import { recordEffectScope } from './effectScope'
5
+ import { activeEffectScope } from './effectScope'
6
6
import { warn } from './warning'
7
7
8
8
export type EffectScheduler = ( ...args : any [ ] ) => any
@@ -137,7 +137,9 @@ export class ReactiveEffect<T = any>
137
137
onTrigger ?: ( event : DebuggerEvent ) => void
138
138
139
139
constructor ( public fn : ( ) => T ) {
140
- recordEffectScope ( this )
140
+ if ( activeEffectScope && activeEffectScope . active ) {
141
+ activeEffectScope . effects . push ( this )
142
+ }
141
143
}
142
144
143
145
/**
Original file line number Diff line number Diff line change 1
1
import type { ReactiveEffect } from './effect'
2
2
import { warn } from './warning'
3
3
4
- let activeEffectScope : EffectScope | undefined
4
+ export let activeEffectScope : EffectScope | undefined
5
5
6
6
export class EffectScope {
7
7
/**
@@ -120,15 +120,6 @@ export function effectScope(detached?: boolean) {
120
120
return new EffectScope ( detached )
121
121
}
122
122
123
- export function recordEffectScope (
124
- effect : ReactiveEffect ,
125
- scope : EffectScope | undefined = activeEffectScope ,
126
- ) {
127
- if ( scope && scope . active ) {
128
- scope . effects . push ( effect )
129
- }
130
- }
131
-
132
123
/**
133
124
* Returns the current active effect scope if there is one.
134
125
*
You can’t perform that action at this time.
0 commit comments