Skip to content

Commit

Permalink
refactor: simplify logic in processComputedUpdate function
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 30, 2025
1 parent 5961b42 commit 50e0b0f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/reactivity/src/system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
// Ported from https://github.com/stackblitz/alien-signals/blob/v1.0.2/src/system.ts
// Ported from https://github.com/stackblitz/alien-signals/blob/v1.0.3/src/system.ts
import type { ComputedRefImpl as Computed } from './computed.js'
import type { ReactiveEffect as Effect } from './effect.js'

Expand Down Expand Up @@ -194,22 +194,18 @@ export function processComputedUpdate(
computed: Computed,
flags: SubscriberFlags,
): void {
if (flags & SubscriberFlags.Dirty) {
if (computed.update()) {
const subs = computed.subs
if (subs !== undefined) {
shallowPropagate(subs)
}
}
} else if (checkDirty(computed.deps!)) {
if (
flags & SubscriberFlags.Dirty ||
(checkDirty(computed.deps!)
? true
: ((computed.flags = flags & ~SubscriberFlags.PendingComputed), false))
) {
if (computed.update()) {
const subs = computed.subs
if (subs !== undefined) {
shallowPropagate(subs)
}
}
} else {
computed.flags = flags & ~SubscriberFlags.PendingComputed
}
}

Expand Down

0 comments on commit 50e0b0f

Please sign in to comment.