internal_set() — svelte Function Reference
Architecture documentation for the internal_set() function in sources.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD fc566ca0_2101_ea1a_cf42_44d2442cc526["internal_set()"] e5c35d51_28d8_9054_923d_b7f82a3c8dc2["sources.js"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|defined in| e5c35d51_28d8_9054_923d_b7f82a3c8dc2 6b775363_a430_a650_b5bb_43f6c298e1fe["await_block()"] 6b775363_a430_a650_b5bb_43f6c298e1fe -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 95fd9978_b635_37dc_dfee_13c687d48cd6["update_pending_count()"] 95fd9978_b635_37dc_dfee_13c687d48cd6 -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 7f76e82e_4ed8_1525_9136_2ae67868d44e["each()"] 7f76e82e_4ed8_1525_9136_2ae67868d44e -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 cc820e63_dbe0_3257_d030_6c750aad368e["invalidate_inner_signals()"] cc820e63_dbe0_3257_d030_6c750aad368e -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 a387a36f_f417_a149_0b1a_ee4a1da63440["async_derived()"] a387a36f_f417_a149_0b1a_ee4a1da63440 -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set()"] 63ee8247_ada4_9f1d_e139_0c1167cd5b1c -->|calls| fc566ca0_2101_ea1a_cf42_44d2442cc526 cba02be5_1b7d_ad21_f54b_8a8a90da7e59["equals()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| cba02be5_1b7d_ad21_f54b_8a8a90da7e59 63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| 63ee8247_ada4_9f1d_e139_0c1167cd5b1c 2ec0d2fd_8bbc_b2ba_53ae_f2da02bb3ba5["ensure()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| 2ec0d2fd_8bbc_b2ba_53ae_f2da02bb3ba5 c6834881_4d11_32ef_6bfe_2be0c88e456b["capture()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| c6834881_4d11_32ef_6bfe_2be0c88e456b a08b6cc5_af73_1be4_d02f_3113cf8a8305["get()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305 cc46feba_170d_5970_a6be_f512f15aa0ee["get_error()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| cc46feba_170d_5970_a6be_f512f15aa0ee 6ac29608_bb3f_4976_22d6_2651518ca4bc["execute_derived()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| 6ac29608_bb3f_4976_22d6_2651518ca4bc 58b2d309_6832_2659_5c05_6923f97c1163["update_derived_status()"] fc566ca0_2101_ea1a_cf42_44d2442cc526 -->|calls| 58b2d309_6832_2659_5c05_6923f97c1163 style fc566ca0_2101_ea1a_cf42_44d2442cc526 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/reactivity/sources.js lines 174–259
export function internal_set(source, value) {
if (!source.equals(value)) {
var old_value = source.v;
if (is_destroying_effect) {
old_values.set(source, value);
} else {
old_values.set(source, old_value);
}
source.v = value;
var batch = Batch.ensure();
batch.capture(source, old_value);
if (DEV) {
if (tracing_mode_flag || active_effect !== null) {
source.updated ??= new Map();
// For performance reasons, when not using $inspect.trace, we only start collecting stack traces
// after the same source has been updated more than 5 times in the same flush cycle.
const count = (source.updated.get('')?.count ?? 0) + 1;
source.updated.set('', { error: /** @type {any} */ (null), count });
if (tracing_mode_flag || count > 5) {
const error = get_error('updated at');
if (error !== null) {
let entry = source.updated.get(error.stack);
if (!entry) {
entry = { error, count: 0 };
source.updated.set(error.stack, entry);
}
entry.count++;
}
}
}
if (active_effect !== null) {
source.set_during_effect = true;
}
}
if ((source.f & DERIVED) !== 0) {
const derived = /** @type {Derived} */ (source);
// if we are assigning to a dirty derived we set it to clean/maybe dirty but we also eagerly execute it to track the dependencies
if ((source.f & DIRTY) !== 0) {
execute_derived(derived);
}
update_derived_status(derived);
}
source.wv = increment_write_version();
// For debugging, in case you want to know which reactions are being scheduled:
// log_reactions(source);
mark_reactions(source, DIRTY);
// It's possible that the current reaction might not have up-to-date dependencies
// whilst it's actively running. So in the case of ensuring it registers the reaction
// properly for itself, we need to ensure the current effect actually gets
// scheduled. i.e: `$effect(() => x++)`
if (
is_runes() &&
active_effect !== null &&
(active_effect.f & CLEAN) !== 0 &&
(active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0
) {
if (untracked_writes === null) {
set_untracked_writes([source]);
} else {
untracked_writes.push(source);
}
}
if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
flush_eager_effects();
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does internal_set() do?
internal_set() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/reactivity/sources.js.
Where is internal_set() defined?
internal_set() is defined in packages/svelte/src/internal/client/reactivity/sources.js at line 174.
What does internal_set() call?
internal_set() calls 14 function(s): capture, ensure, equals, execute_derived, flush_eager_effects, get, get_error, increment_write_version, and 6 more.
What calls internal_set()?
internal_set() is called by 6 function(s): async_derived, await_block, each, invalidate_inner_signals, set, update_pending_count.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free