Skip to content

Commit

Permalink
Sync alien-signals 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Nov 21, 2024
1 parent 0e5d59f commit f15e9d7
Showing 1 changed file with 11 additions and 36 deletions.
47 changes: 11 additions & 36 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function cleanupEffect(e: ReactiveEffect) {
}
}

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

top: do {
const dep = deps.dep
Expand All @@ -544,44 +546,17 @@ export function checkDirty(deps: Link): boolean {
++stack
continue
}
if (dirtyLevel === DirtyLevels.Dirty) {
if (dep.update()) {
propagate(dep.subs!)
let dirty = true
if (stack > 0) {
let sub = deps.sub as IComputed
do {
--stack
const subSubs = sub.subs!
const prevLink = subSubs.prevSub!
subSubs.prevSub = undefined
if (dirty) {
if (sub.update()) {
propagate(subSubs)
deps = prevLink
sub = prevLink.sub as IComputed
dirty = true
continue
}
} else {
sub.dirtyLevel = DirtyLevels.None
}
deps = prevLink.nextDep!
if (deps !== undefined) {
continue top
}
dirty = false
sub = prevLink.sub as IComputed
} while (stack > 0)
}
return dirty
}
if (dirtyLevel === DirtyLevels.Dirty && dep.update()) {
propagate(dep.subs!)
dirty = true
} else {
dirty = false
}
} else {
dirty = false
}

const nextDep = deps.nextDep!
if (nextDep === undefined) {
let dirty = false
if (dirty || (nextDep = deps.nextDep) === undefined) {
if (stack > 0) {
let sub = deps.sub as IComputed
do {
Expand Down

0 comments on commit f15e9d7

Please sign in to comment.