flush_queued_effects() — svelte Function Reference
Architecture documentation for the flush_queued_effects() function in batch.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 3991a63f_13e1_fb44_3044_00252e1380f3["flush_queued_effects()"] d8e42d9d_2e3c_635c_19d3_b946a4341c0f["batch.js"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|defined in| d8e42d9d_2e3c_635c_19d3_b946a4341c0f 05511be0_1e56_3876_59e2_7350fc912bb9["process()"] 05511be0_1e56_3876_59e2_7350fc912bb9 -->|calls| 3991a63f_13e1_fb44_3044_00252e1380f3 9d7b1994_c635_b82f_ff1f_b19fc461c425["is_dirty()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| 9d7b1994_c635_b82f_ff1f_b19fc461c425 19374192_7fff_dd82_3581_d62b472dfbdd["update_effect()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| 19374192_7fff_dd82_3581_d62b472dfbdd 9ff5deaa_0417_faaf_da92_5b566dc2b490["effects()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| 9ff5deaa_0417_faaf_da92_5b566dc2b490 a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| a985ae40_8ef8_7ef2_adad_116fbf97e70c 53f32138_2bfa_6668_a79e_c1714a9e27fe["unlink_effect()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| 53f32138_2bfa_6668_a79e_c1714a9e27fe 5bc3c950_96f7_e454_6cb7_65ffc2179811["flushSync()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| 5bc3c950_96f7_e454_6cb7_65ffc2179811 a199a3f7_5497_5329_2c7c_fc4555548da6["clear()"] 3991a63f_13e1_fb44_3044_00252e1380f3 -->|calls| a199a3f7_5497_5329_2c7c_fc4555548da6 style 3991a63f_13e1_fb44_3044_00252e1380f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/reactivity/batch.js lines 685–751
function flush_queued_effects(effects) {
var length = effects.length;
if (length === 0) return;
var i = 0;
while (i < length) {
var effect = effects[i++];
if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
eager_block_effects = new Set();
update_effect(effect);
// Effects with no dependencies or teardown do not get added to the effect tree.
// Deferred effects (e.g. `$effect(...)`) _are_ added to the tree because we
// don't know if we need to keep them until they are executed. Doing the check
// here (rather than in `update_effect`) allows us to skip the work for
// immediate effects.
if (effect.deps === null && effect.first === null && effect.nodes === null) {
// if there's no teardown or abort controller we completely unlink
// the effect from the graph
if (effect.teardown === null && effect.ac === null) {
// remove this effect from the graph
unlink_effect(effect);
} else {
// keep the effect in the graph, but free up some memory
effect.fn = null;
}
}
// If update_effect() has a flushSync() in it, we may have flushed another flush_queued_effects(),
// which already handled this logic and did set eager_block_effects to null.
if (eager_block_effects?.size > 0) {
old_values.clear();
for (const e of eager_block_effects) {
// Skip eager effects that have already been unmounted
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
// Run effects in order from ancestor to descendant, else we could run into nullpointers
/** @type {Effect[]} */
const ordered_effects = [e];
let ancestor = e.parent;
while (ancestor !== null) {
if (eager_block_effects.has(ancestor)) {
eager_block_effects.delete(ancestor);
ordered_effects.push(ancestor);
}
ancestor = ancestor.parent;
}
for (let j = ordered_effects.length - 1; j >= 0; j--) {
const e = ordered_effects[j];
// Skip eager effects that have already been unmounted
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
update_effect(e);
}
}
eager_block_effects.clear();
}
}
}
eager_block_effects = null;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does flush_queued_effects() do?
flush_queued_effects() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/reactivity/batch.js.
Where is flush_queued_effects() defined?
flush_queued_effects() is defined in packages/svelte/src/internal/client/reactivity/batch.js at line 685.
What does flush_queued_effects() call?
flush_queued_effects() calls 7 function(s): clear, effect, effects, flushSync, is_dirty, unlink_effect, update_effect.
What calls flush_queued_effects()?
flush_queued_effects() is called by 1 function(s): process.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free