eager() — svelte Function Reference
Architecture documentation for the eager() function in batch.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 92a6b0f5_8829_33ec_80dd_aa943970a578["eager()"] d8e42d9d_2e3c_635c_19d3_b946a4341c0f["batch.js"] 92a6b0f5_8829_33ec_80dd_aa943970a578 -->|defined in| d8e42d9d_2e3c_635c_19d3_b946a4341c0f a967b3b9_6263_60ec_74ff_b1889e66d284["fork()"] a967b3b9_6263_60ec_74ff_b1889e66d284 -->|calls| 92a6b0f5_8829_33ec_80dd_aa943970a578 1e2f7428_6050_5cb7_69db_bf5db719f6d1["source()"] 92a6b0f5_8829_33ec_80dd_aa943970a578 -->|calls| 1e2f7428_6050_5cb7_69db_bf5db719f6d1 a08b6cc5_af73_1be4_d02f_3113cf8a8305["get()"] 92a6b0f5_8829_33ec_80dd_aa943970a578 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305 80b95503_e5bc_4965_f8d9_a5ec40e8e1c2["eager_effect()"] 92a6b0f5_8829_33ec_80dd_aa943970a578 -->|calls| 80b95503_e5bc_4965_f8d9_a5ec40e8e1c2 2cab0f64_6d19_d981_66e2_d2555c252702["queue_micro_task()"] 92a6b0f5_8829_33ec_80dd_aa943970a578 -->|calls| 2cab0f64_6d19_d981_66e2_d2555c252702 style 92a6b0f5_8829_33ec_80dd_aa943970a578 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/reactivity/batch.js lines 886–922
export function eager(fn) {
var version = source(0);
var initial = true;
var value = /** @type {T} */ (undefined);
get(version);
eager_effect(() => {
if (initial) {
// the first time this runs, we create an eager effect
// that will run eagerly whenever the expression changes
var previous_batch_values = batch_values;
try {
batch_values = null;
value = fn();
} finally {
batch_values = previous_batch_values;
}
return;
}
// the second time this effect runs, it's to schedule a
// `version` update. since this will recreate the effect,
// we don't need to evaluate the expression here
if (eager_versions.length === 0) {
queue_micro_task(eager_flush);
}
eager_versions.push(version);
});
initial = false;
return value;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does eager() do?
eager() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/reactivity/batch.js.
Where is eager() defined?
eager() is defined in packages/svelte/src/internal/client/reactivity/batch.js at line 886.
What does eager() call?
eager() calls 4 function(s): eager_effect, get, queue_micro_task, source.
What calls eager()?
eager() is called by 1 function(s): fork.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free