*/
ALLOW_RECURSE = 1 << 7,
PAUSED = 1 << 8,
+ STOP = 1 << 10,
}
export class ReactiveEffect<T = any>
}
get active(): boolean {
- return !!this.flags || this.deps !== undefined
+ return !(this.flags & EffectFlags.STOP)
}
pause(): void {
}
stop(): void {
+ if (!this.active) {
+ return
+ }
+ this.flags = EffectFlags.STOP
let dep = this.deps
while (dep !== undefined) {
dep = unlink(dep, this)
if (sub !== undefined) {
unlink(sub)
}
- this.flags = 0
cleanup(this)
}
}
get active(): boolean {
- return !!this.flags || this.deps !== undefined
+ return !(this.flags & EffectFlags.STOP)
}
pause(): void {
}
stop(): void {
+ if (!this.active) {
+ return
+ }
+ this.flags = EffectFlags.STOP
let dep = this.deps
while (dep !== undefined) {
const node = dep.dep
if (sub !== undefined) {
unlink(sub)
}
- this.flags = 0
cleanup(this)
}
}