refactor: improve flush condition clarity in revive() method

pull/17307/head
harshitydv1 2 days ago
parent 04b686b241
commit 89c2a32f8d

@ -304,7 +304,7 @@ export class Batch {
dep.f ^= WAS_MARKED;
this.#clear_marked(/** @type {Derived} */ (dep).deps);
this.#clear_marked(/** @type {Derived} */(dep).deps);
}
}
@ -503,8 +503,8 @@ export class Batch {
this.#dirty_effects = [];
this.#maybe_dirty_effects = [];
// Always flush if we have pending work that needs to be resolved
if (this.#pending === 0 || queued_root_effects.length > 0) {
// Flush if there are queued root effects, or if there is no pending work left.
if (queued_root_effects.length > 0 || this.#pending === 0) {
this.flush();
}
@ -789,14 +789,14 @@ function mark_effects(value, sources, marked, checked) {
const flags = reaction.f;
if ((flags & DERIVED) !== 0) {
mark_effects(/** @type {Derived} */ (reaction), sources, marked, checked);
mark_effects(/** @type {Derived} */(reaction), sources, marked, checked);
} else if (
(flags & (ASYNC | BLOCK_EFFECT)) !== 0 &&
(flags & DIRTY) === 0 &&
depends_on(reaction, sources, checked)
) {
set_signal_status(reaction, DIRTY);
schedule_effect(/** @type {Effect} */ (reaction));
schedule_effect(/** @type {Effect} */(reaction));
}
}
}
@ -816,10 +816,10 @@ function mark_eager_effects(value, effects) {
const flags = reaction.f;
if ((flags & DERIVED) !== 0) {
mark_eager_effects(/** @type {Derived} */ (reaction), effects);
mark_eager_effects(/** @type {Derived} */(reaction), effects);
} else if ((flags & EAGER_EFFECT) !== 0) {
set_signal_status(reaction, DIRTY);
effects.add(/** @type {Effect} */ (reaction));
effects.add(/** @type {Effect} */(reaction));
}
}
}
@ -839,8 +839,8 @@ function depends_on(reaction, sources, checked) {
return true;
}
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */ (dep), sources, checked)) {
checked.set(/** @type {Derived} */ (dep), true);
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */(dep), sources, checked)) {
checked.set(/** @type {Derived} */(dep), true);
return true;
}
}

Loading…
Cancel
Save