Skip to content

Commit f15e9d7

Browse files
committed
Sync alien-signals 0.3.2
1 parent 0e5d59f commit f15e9d7

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

packages/reactivity/src/effect.ts

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function cleanupEffect(e: ReactiveEffect) {
313313
}
314314
}
315315

316-
//#region Ported from https://github.com/stackblitz/alien-signals/blob/v0.3.1/src/system.ts
316+
//#region Ported from https://github.com/stackblitz/alien-signals/blob/v0.3.2/src/system.ts
317317
export interface IEffect extends Subscriber {
318318
nextNotify: IEffect | undefined
319319
notify(): void
@@ -532,6 +532,8 @@ export function propagate(subs: Link): void {
532532
//#region Subscriber
533533
export function checkDirty(deps: Link): boolean {
534534
let stack = 0
535+
let dirty: boolean
536+
let nextDep: Link | undefined
535537

536538
top: do {
537539
const dep = deps.dep
@@ -544,44 +546,17 @@ export function checkDirty(deps: Link): boolean {
544546
++stack
545547
continue
546548
}
547-
if (dirtyLevel === DirtyLevels.Dirty) {
548-
if (dep.update()) {
549-
propagate(dep.subs!)
550-
let dirty = true
551-
if (stack > 0) {
552-
let sub = deps.sub as IComputed
553-
do {
554-
--stack
555-
const subSubs = sub.subs!
556-
const prevLink = subSubs.prevSub!
557-
subSubs.prevSub = undefined
558-
if (dirty) {
559-
if (sub.update()) {
560-
propagate(subSubs)
561-
deps = prevLink
562-
sub = prevLink.sub as IComputed
563-
dirty = true
564-
continue
565-
}
566-
} else {
567-
sub.dirtyLevel = DirtyLevels.None
568-
}
569-
deps = prevLink.nextDep!
570-
if (deps !== undefined) {
571-
continue top
572-
}
573-
dirty = false
574-
sub = prevLink.sub as IComputed
575-
} while (stack > 0)
576-
}
577-
return dirty
578-
}
549+
if (dirtyLevel === DirtyLevels.Dirty && dep.update()) {
550+
propagate(dep.subs!)
551+
dirty = true
552+
} else {
553+
dirty = false
579554
}
555+
} else {
556+
dirty = false
580557
}
581558

582-
const nextDep = deps.nextDep!
583-
if (nextDep === undefined) {
584-
let dirty = false
559+
if (dirty || (nextDep = deps.nextDep) === undefined) {
585560
if (stack > 0) {
586561
let sub = deps.sub as IComputed
587562
do {

0 commit comments

Comments
 (0)