File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export enum EffectFlags {
52
52
*/
53
53
ALLOW_RECURSE = 1 << 7 ,
54
54
PAUSED = 1 << 8 ,
55
+ STOP = 1 << 10 ,
55
56
}
56
57
57
58
export class ReactiveEffect < T = any >
@@ -90,7 +91,7 @@ export class ReactiveEffect<T = any>
90
91
}
91
92
92
93
get active ( ) : boolean {
93
- return ! ! this . flags || this . deps !== undefined
94
+ return ! ( this . flags & EffectFlags . STOP )
94
95
}
95
96
96
97
pause ( ) : void {
@@ -132,6 +133,10 @@ export class ReactiveEffect<T = any>
132
133
}
133
134
134
135
stop ( ) : void {
136
+ if ( ! this . active ) {
137
+ return
138
+ }
139
+ this . flags = EffectFlags . STOP
135
140
let dep = this . deps
136
141
while ( dep !== undefined ) {
137
142
dep = unlink ( dep , this )
@@ -140,7 +145,6 @@ export class ReactiveEffect<T = any>
140
145
if ( sub !== undefined ) {
141
146
unlink ( sub )
142
147
}
143
- this . flags = 0
144
148
cleanup ( this )
145
149
}
146
150
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export class EffectScope implements ReactiveNode {
33
33
}
34
34
35
35
get active ( ) : boolean {
36
- return ! ! this . flags || this . deps !== undefined
36
+ return ! ( this . flags & EffectFlags . STOP )
37
37
}
38
38
39
39
pause ( ) : void {
@@ -77,6 +77,10 @@ export class EffectScope implements ReactiveNode {
77
77
}
78
78
79
79
stop ( ) : void {
80
+ if ( ! this . active ) {
81
+ return
82
+ }
83
+ this . flags = EffectFlags . STOP
80
84
let dep = this . deps
81
85
while ( dep !== undefined ) {
82
86
const node = dep . dep
@@ -91,7 +95,6 @@ export class EffectScope implements ReactiveNode {
91
95
if ( sub !== undefined ) {
92
96
unlink ( sub )
93
97
}
94
- this . flags = 0
95
98
cleanup ( this )
96
99
}
97
100
}
You can’t perform that action at this time.
0 commit comments