remove_reaction() — svelte Function Reference
Architecture documentation for the remove_reaction() function in runtime.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 1705239c_1015_839e_cc01_7ff4d8e46bb2["remove_reaction()"] bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] 1705239c_1015_839e_cc01_7ff4d8e46bb2 -->|defined in| bde4209f_8ffc_1594_4024_b1835a44bcf6 1ffeab26_17a7_43c8_1f19_a6f67d2606ea["remove_reactions()"] 1ffeab26_17a7_43c8_1f19_a6f67d2606ea -->|calls| 1705239c_1015_839e_cc01_7ff4d8e46bb2 7114b424_5006_2886_1565_8d8123ef1ad8["pop()"] 1705239c_1015_839e_cc01_7ff4d8e46bb2 -->|calls| 7114b424_5006_2886_1565_8d8123ef1ad8 58b2d309_6832_2659_5c05_6923f97c1163["update_derived_status()"] 1705239c_1015_839e_cc01_7ff4d8e46bb2 -->|calls| 58b2d309_6832_2659_5c05_6923f97c1163 6a7c7098_bda5_0254_e673_2f75f156c2d5["destroy_derived_effects()"] 1705239c_1015_839e_cc01_7ff4d8e46bb2 -->|calls| 6a7c7098_bda5_0254_e673_2f75f156c2d5 1ffeab26_17a7_43c8_1f19_a6f67d2606ea["remove_reactions()"] 1705239c_1015_839e_cc01_7ff4d8e46bb2 -->|calls| 1ffeab26_17a7_43c8_1f19_a6f67d2606ea style 1705239c_1015_839e_cc01_7ff4d8e46bb2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/internal/client/runtime.js lines 362–403
function remove_reaction(signal, dependency) {
let reactions = dependency.reactions;
if (reactions !== null) {
var index = index_of.call(reactions, signal);
if (index !== -1) {
var new_length = reactions.length - 1;
if (new_length === 0) {
reactions = dependency.reactions = null;
} else {
// Swap with last element and then remove.
reactions[index] = reactions[new_length];
reactions.pop();
}
}
}
// If the derived has no reactions, then we can disconnect it from the graph,
// allowing it to either reconnect in the future, or be GC'd by the VM.
if (
reactions === null &&
(dependency.f & DERIVED) !== 0 &&
// Destroying a child effect while updating a parent effect can cause a dependency to appear
// to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
// allows us to skip the expensive work of disconnecting and immediately reconnecting it
(new_deps === null || !includes.call(new_deps, dependency))
) {
var derived = /** @type {Derived} */ (dependency);
// If we are working with a derived that is owned by an effect, then mark it as being
// disconnected and remove the mark flag, as it cannot be reliably removed otherwise
if ((derived.f & CONNECTED) !== 0) {
derived.f ^= CONNECTED;
derived.f &= ~WAS_MARKED;
}
update_derived_status(derived);
// Disconnect any reactions owned by this reaction
destroy_derived_effects(derived);
remove_reactions(derived, 0);
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does remove_reaction() do?
remove_reaction() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/runtime.js.
Where is remove_reaction() defined?
remove_reaction() is defined in packages/svelte/src/internal/client/runtime.js at line 362.
What does remove_reaction() call?
remove_reaction() calls 4 function(s): destroy_derived_effects, pop, remove_reactions, update_derived_status.
What calls remove_reaction()?
remove_reaction() is called by 1 function(s): remove_reactions.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free