File tree Expand file tree Collapse file tree 4 files changed +16
-17
lines changed Expand file tree Collapse file tree 4 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,6 @@ export class ComputedRefImpl<T> {
49
49
this [ ReactiveFlags . IS_READONLY ] = isReadonly
50
50
}
51
51
52
- queryDirty ( ) {
53
- return this . value
54
- }
55
-
56
52
get value ( ) {
57
53
// the computed ref may get wrapped by other proxies e.g. readonly() #3376
58
54
const self = toRaw ( this )
Original file line number Diff line number Diff line change 1
- import { ReactiveEffect } from './effect'
1
+ import type { ReactiveEffect } from './effect'
2
+ import type { ComputedRefImpl } from './computed'
2
3
3
4
export type Dep = Map < ReactiveEffect , number > & {
4
- queryDirty ?: ( ) => void
5
+ computed ?: ComputedRefImpl < any >
5
6
}
6
7
7
- export const createDep = ( queryDirty ?: ( ) => void ) : Dep => {
8
+ export const createDep = ( computed ?: ComputedRefImpl < any > ) : Dep => {
8
9
const dep : Dep = new Map ( )
9
- dep . queryDirty = queryDirty
10
+ dep . computed = computed
10
11
return dep
11
12
}
Original file line number Diff line number Diff line change @@ -74,9 +74,11 @@ export class ReactiveEffect<T = any> {
74
74
this . _queryingDirty = true
75
75
pauseTracking ( )
76
76
for ( const dep of this . deps ) {
77
- dep . queryDirty ?.( )
78
- if ( this . _dirtyLevel >= DirtyLevels . ComputedValueDirty ) {
79
- break
77
+ if ( dep . computed ) {
78
+ triggerComputed ( dep . computed )
79
+ if ( this . _dirtyLevel >= DirtyLevels . ComputedValueDirty ) {
80
+ break
81
+ }
80
82
}
81
83
}
82
84
resetTracking ( )
@@ -120,6 +122,10 @@ export class ReactiveEffect<T = any> {
120
122
}
121
123
}
122
124
125
+ function triggerComputed ( computed : ComputedRefImpl < any > ) {
126
+ return computed . value
127
+ }
128
+
123
129
function cleanupEffect ( effect : ReactiveEffect ) {
124
130
effect . _trackId ++
125
131
effect . _depsLength = 0
Original file line number Diff line number Diff line change @@ -46,9 +46,7 @@ export function trackRefValue(ref: RefBase<any>) {
46
46
activeEffect ,
47
47
ref . dep ||
48
48
( ref . dep = createDep (
49
- ref instanceof ComputedRefImpl
50
- ? ref . queryDirty . bind ( ref )
51
- : undefined
49
+ ref instanceof ComputedRefImpl ? ref : undefined
52
50
) ) ,
53
51
{
54
52
target : ref ,
@@ -61,9 +59,7 @@ export function trackRefValue(ref: RefBase<any>) {
61
59
activeEffect ,
62
60
ref . dep ||
63
61
( ref . dep = createDep (
64
- ref instanceof ComputedRefImpl
65
- ? ref . queryDirty . bind ( ref )
66
- : undefined
62
+ ref instanceof ComputedRefImpl ? ref : undefined
67
63
) )
68
64
)
69
65
}
You can’t perform that action at this time.
0 commit comments