Skip to content

Commit

Permalink
refactor(computed): deprecated computedRunners (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pick authored Jul 1, 2020
1 parent f6da6bf commit 5c490f1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
1 change: 0 additions & 1 deletion packages/reactivity/src/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@danyadev

danyadev Jul 1, 2020

here the comment seems redundant

This comment has been minimized.

Copy link
@Picknight

Picknight Jul 2, 2020

Contributor

Yes, I delete it.

computed: true,
scheduler: () => {
if (!dirty) {
dirty = true
Expand Down
10 changes: 1 addition & 9 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down Expand Up @@ -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)
}

0 comments on commit 5c490f1

Please sign in to comment.