refactor(computed): deprecated computedRunners (#1458)

This commit is contained in:
Pick 2020-07-02 03:39:13 +08:00 committed by GitHub
parent f6da6bf999
commit 5c490f1c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 10 deletions

View File

@ -48,7 +48,6 @@ export function computed<T>(
const runner = effect(getter, {
lazy: true,
// mark effect as computed so that it gets priority during trigger
computed: true,
scheduler: () => {
if (!dirty) {
dirty = true

View File

@ -177,16 +177,11 @@ export function trigger(
}
const effects = new Set<ReactiveEffect>()
const computedRunners = new Set<ReactiveEffect>()
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || !shouldTrack) {
if (effect.options.computed) {
computedRunners.add(effect)
} else {
effects.add(effect)
}
effects.add(effect)
} else {
// the effect mutated its own dependency during its execution.
// this can be caused by operations like foo.value++
@ -245,8 +240,5 @@ export function trigger(
}
}
// Important: computed effects must be run first so that computed getters
// can be invalidated before any normal effects that depend on them are run.
computedRunners.forEach(run)
effects.forEach(run)
}