Skip to content

refactor(effect): tweak arguments #8947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(effect): ♻️ tweak arguments
  • Loading branch information
Liberty-liu committed Aug 11, 2023
commit 9c1352b21857bee0d5abe44f7365fb6b9fa487f0
29 changes: 11 additions & 18 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,26 +367,19 @@ export function trigger(
? { target, type, key, newValue, oldValue, oldTarget }
: undefined

if (deps.length === 1) {
if (deps[0]) {
if (__DEV__) {
triggerEffects(deps[0], eventInfo)
} else {
triggerEffects(deps[0])
}
const effects: ReactiveEffect[] = []
for (const dep of deps) {
if (dep) {
effects.push(...dep)
}
}
if (__DEV__) {
triggerEffects(
effects.length === 1 ? effects : createDep(effects),
eventInfo
)
} else {
const effects: ReactiveEffect[] = []
for (const dep of deps) {
if (dep) {
effects.push(...dep)
}
}
if (__DEV__) {
triggerEffects(createDep(effects), eventInfo)
} else {
triggerEffects(createDep(effects))
}
triggerEffects(effects.length === 1 ? effects : createDep(effects))
}
}

Expand Down