Skip to content

Commit 81a6708

Browse files
committed
chore: simplify effectScope
1 parent 2993a24 commit 81a6708

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,22 @@ export class EffectScope {
2929
run<T>(fn: () => T): T | undefined {
3030
if (this.active) {
3131
try {
32-
this.on()
32+
activeEffectScope = this
3333
return fn()
3434
} finally {
35-
this.off()
35+
activeEffectScope = this.parent
3636
}
3737
} else if (__DEV__) {
3838
warn(`cannot run an inactive effect scope.`)
3939
}
4040
}
4141

4242
on() {
43-
if (this.active) {
44-
activeEffectScope = this
45-
}
43+
activeEffectScope = this
4644
}
4745

4846
off() {
49-
if (this.active) {
50-
activeEffectScope = this.parent
51-
}
47+
activeEffectScope = this.parent
5248
}
5349

5450
stop(fromParent?: boolean) {

0 commit comments

Comments
 (0)