@@ -9,15 +9,15 @@ import {
9
9
type Link ,
10
10
activeSub ,
11
11
activeTrackId ,
12
+ checkDirty ,
12
13
endTrack ,
13
14
link ,
14
15
propagate ,
15
- resolveMaybeDirty ,
16
16
startTrack ,
17
17
} from './effect'
18
+ import { activeEffectScope } from './effectScope'
18
19
import type { Ref } from './ref'
19
20
import { warn } from './warning'
20
- import { activeEffectScope } from './effectScope'
21
21
22
22
declare const ComputedRefSymbol : unique symbol
23
23
declare const WritableComputedRefSymbol : unique symbol
@@ -90,10 +90,14 @@ export class ComputedRefImpl<T = any> implements IComputed {
90
90
get _dirty ( ) : boolean {
91
91
let dirtyLevel = this . dirtyLevel
92
92
if ( dirtyLevel === DirtyLevels . MaybeDirty ) {
93
- resolveMaybeDirty ( this )
94
- dirtyLevel = this . dirtyLevel
93
+ if ( checkDirty ( this . deps ! ) ) {
94
+ return true
95
+ } else {
96
+ this . dirtyLevel = DirtyLevels . None
97
+ return false
98
+ }
95
99
}
96
- return dirtyLevel > = DirtyLevels . Dirty
100
+ return dirtyLevel == = DirtyLevels . Dirty
97
101
}
98
102
set _dirty ( v : boolean ) {
99
103
if ( v ) {
@@ -126,7 +130,12 @@ export class ComputedRefImpl<T = any> implements IComputed {
126
130
127
131
get value ( ) : T {
128
132
if ( this . _dirty ) {
129
- this . update ( )
133
+ if ( this . update ( ) ) {
134
+ const subs = this . subs
135
+ if ( subs !== undefined ) {
136
+ propagate ( subs )
137
+ }
138
+ }
130
139
}
131
140
if ( activeTrackId !== 0 ) {
132
141
const subsTail = this . subsTail
@@ -154,7 +163,7 @@ export class ComputedRefImpl<T = any> implements IComputed {
154
163
}
155
164
}
156
165
157
- update ( ) : void {
166
+ update ( ) : boolean {
158
167
const prevSub = startTrack ( this )
159
168
const oldValue = this . _value
160
169
let newValue : T
@@ -165,11 +174,9 @@ export class ComputedRefImpl<T = any> implements IComputed {
165
174
}
166
175
if ( hasChanged ( oldValue , newValue ) ) {
167
176
this . _value = newValue
168
- const subs = this . subs
169
- if ( subs !== undefined ) {
170
- propagate ( subs )
171
- }
177
+ return true
172
178
}
179
+ return false
173
180
}
174
181
}
175
182
0 commit comments