Skip to content

Commit

Permalink
refactor(reactivity): simplify if condition (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
limichange authored Apr 20, 2020
1 parent 6390093 commit fa40d1e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ export function track(target: object, type: TrackOpTypes, key: unknown) {
return
}
let depsMap = targetMap.get(target)
if (depsMap === void 0) {
if (!depsMap) {
targetMap.set(target, (depsMap = new Map()))
}
let dep = depsMap.get(key)
if (dep === void 0) {
if (!dep) {
depsMap.set(key, (dep = new Set()))
}
if (!dep.has(activeEffect)) {
Expand All @@ -171,15 +171,15 @@ export function trigger(
oldTarget?: Map<unknown, unknown> | Set<unknown>
) {
const depsMap = targetMap.get(target)
if (depsMap === void 0) {
if (!depsMap) {
// never been tracked
return
}

const effects = new Set<ReactiveEffect>()
const computedRunners = new Set<ReactiveEffect>()
const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
if (effectsToAdd !== void 0) {
if (effectsToAdd) {
effectsToAdd.forEach(effect => {
if (effect !== activeEffect || !shouldTrack) {
if (effect.options.computed) {
Expand Down Expand Up @@ -238,7 +238,7 @@ export function trigger(
oldTarget
})
}
if (effect.options.scheduler !== void 0) {
if (effect.options.scheduler) {
effect.options.scheduler(effect)
} else {
effect()
Expand Down

0 comments on commit fa40d1e

Please sign in to comment.