@@ -3,12 +3,17 @@ import { ReactiveFlags, TrackOpTypes } from './constants'
3
3
import { onTrack , setupDirtyLevelHandler } from './debug'
4
4
import type { DebuggerEvent , DebuggerOptions } from './effect'
5
5
import {
6
- Dependency ,
6
+ type Dependency ,
7
7
DirtyLevels ,
8
8
type IComputed ,
9
9
type Link ,
10
- Subscriber ,
11
- System ,
10
+ activeSub ,
11
+ activeTrackId ,
12
+ endTrack ,
13
+ link ,
14
+ propagate ,
15
+ resolveMaybeDirty ,
16
+ startTrack ,
12
17
} from './effect'
13
18
import type { Ref } from './ref'
14
19
import { warn } from './warning'
@@ -85,7 +90,7 @@ export class ComputedRefImpl<T = any> implements IComputed {
85
90
get _dirty ( ) : boolean {
86
91
let dirtyLevel = this . dirtyLevel
87
92
if ( dirtyLevel === DirtyLevels . MaybeDirty ) {
88
- Subscriber . resolveMaybeDirty ( this )
93
+ resolveMaybeDirty ( this )
89
94
dirtyLevel = this . dirtyLevel
90
95
}
91
96
return dirtyLevel >= DirtyLevels . Dirty
@@ -123,21 +128,20 @@ export class ComputedRefImpl<T = any> implements IComputed {
123
128
if ( this . _dirty ) {
124
129
this . update ( )
125
130
}
126
- const activeTrackId = System . activeTrackId
127
131
if ( activeTrackId !== 0 ) {
128
132
const subsTail = this . subsTail
129
133
if ( subsTail === undefined || subsTail . trackId !== activeTrackId ) {
130
134
if ( __DEV__ ) {
131
- onTrack ( System . activeSub ! , {
135
+ onTrack ( activeSub ! , {
132
136
target : this ,
133
137
type : TrackOpTypes . GET ,
134
138
key : 'value' ,
135
139
} )
136
140
}
137
- Dependency . link ( this , System . activeSub ! )
141
+ link ( this , activeSub ! )
138
142
}
139
143
} else if ( activeEffectScope !== undefined ) {
140
- Dependency . link ( this , activeEffectScope )
144
+ link ( this , activeEffectScope )
141
145
}
142
146
return this . _value !
143
147
}
@@ -151,19 +155,19 @@ export class ComputedRefImpl<T = any> implements IComputed {
151
155
}
152
156
153
157
update ( ) : void {
154
- const prevSub = Subscriber . startTrack ( this )
158
+ const prevSub = startTrack ( this )
155
159
const oldValue = this . _value
156
160
let newValue : T
157
161
try {
158
162
newValue = this . fn ( oldValue )
159
163
} finally {
160
- Subscriber . endTrack ( this , prevSub )
164
+ endTrack ( this , prevSub )
161
165
}
162
166
if ( hasChanged ( oldValue , newValue ) ) {
163
167
this . _value = newValue
164
168
const subs = this . subs
165
169
if ( subs !== undefined ) {
166
- Dependency . propagate ( subs )
170
+ propagate ( subs )
167
171
}
168
172
}
169
173
}
0 commit comments