Skip to content

Commit 50e0b0f

Browse files
committed
refactor: simplify logic in processComputedUpdate function
1 parent 5961b42 commit 50e0b0f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/reactivity/src/system.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
2-
// Ported from https://github.com/stackblitz/alien-signals/blob/v1.0.2/src/system.ts
2+
// Ported from https://github.com/stackblitz/alien-signals/blob/v1.0.3/src/system.ts
33
import type { ComputedRefImpl as Computed } from './computed.js'
44
import type { ReactiveEffect as Effect } from './effect.js'
55

@@ -194,22 +194,18 @@ export function processComputedUpdate(
194194
computed: Computed,
195195
flags: SubscriberFlags,
196196
): void {
197-
if (flags & SubscriberFlags.Dirty) {
198-
if (computed.update()) {
199-
const subs = computed.subs
200-
if (subs !== undefined) {
201-
shallowPropagate(subs)
202-
}
203-
}
204-
} else if (checkDirty(computed.deps!)) {
197+
if (
198+
flags & SubscriberFlags.Dirty ||
199+
(checkDirty(computed.deps!)
200+
? true
201+
: ((computed.flags = flags & ~SubscriberFlags.PendingComputed), false))
202+
) {
205203
if (computed.update()) {
206204
const subs = computed.subs
207205
if (subs !== undefined) {
208206
shallowPropagate(subs)
209207
}
210208
}
211-
} else {
212-
computed.flags = flags & ~SubscriberFlags.PendingComputed
213209
}
214210
}
215211

0 commit comments

Comments
 (0)