chore: simplify effectScope
This commit is contained in:
parent
2993a24618
commit
81a6708739
|
@ -29,10 +29,10 @@ export class EffectScope {
|
||||||
run<T>(fn: () => T): T | undefined {
|
run<T>(fn: () => T): T | undefined {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
try {
|
try {
|
||||||
this.on()
|
activeEffectScope = this
|
||||||
return fn()
|
return fn()
|
||||||
} finally {
|
} finally {
|
||||||
this.off()
|
activeEffectScope = this.parent
|
||||||
}
|
}
|
||||||
} else if (__DEV__) {
|
} else if (__DEV__) {
|
||||||
warn(`cannot run an inactive effect scope.`)
|
warn(`cannot run an inactive effect scope.`)
|
||||||
|
@ -40,16 +40,12 @@ export class EffectScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
on() {
|
on() {
|
||||||
if (this.active) {
|
|
||||||
activeEffectScope = this
|
activeEffectScope = this
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
off() {
|
off() {
|
||||||
if (this.active) {
|
|
||||||
activeEffectScope = this.parent
|
activeEffectScope = this.parent
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stop(fromParent?: boolean) {
|
stop(fromParent?: boolean) {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
|
|
Loading…
Reference in New Issue