mirror of https://github.com/vuejs/core.git
fix(reactivity): allow collect effects in EffectScope (#13657)
close #13656
This commit is contained in:
parent
3cb27d156f
commit
b9fb79a1fd
|
@ -1,11 +1,5 @@
|
||||||
import { EffectFlags, cleanup } from './effect'
|
import { EffectFlags, cleanup } from './effect'
|
||||||
import {
|
import { type Link, type ReactiveNode, link, unlink } from './system'
|
||||||
type Link,
|
|
||||||
type ReactiveNode,
|
|
||||||
link,
|
|
||||||
setActiveSub,
|
|
||||||
unlink,
|
|
||||||
} from './system'
|
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
|
|
||||||
export let activeEffectScope: EffectScope | undefined
|
export let activeEffectScope: EffectScope | undefined
|
||||||
|
@ -65,14 +59,12 @@ export class EffectScope implements ReactiveNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
run<T>(fn: () => T): T | undefined {
|
run<T>(fn: () => T): T | undefined {
|
||||||
const prevSub = setActiveSub()
|
|
||||||
const prevScope = activeEffectScope
|
const prevScope = activeEffectScope
|
||||||
try {
|
try {
|
||||||
activeEffectScope = this
|
activeEffectScope = this
|
||||||
return fn()
|
return fn()
|
||||||
} finally {
|
} finally {
|
||||||
activeEffectScope = prevScope
|
activeEffectScope = prevScope
|
||||||
setActiveSub(prevSub)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue