actions.js — svelte Source File
Architecture documentation for actions.js, a javascript file in the svelte codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 8a7e1359_80ee_d99b_c857_a4077af52e5a["actions.js"] 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb["effects.js"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> a985ae40_8ef8_7ef2_adad_116fbf97e70c 7494b934_a3b8_689e_91b6_8435e26461c5["render_effect"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> 7494b934_a3b8_689e_91b6_8435e26461c5 9068d26c_037d_ff15_43b8_824380424345["equality.js"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> 9068d26c_037d_ff15_43b8_824380424345 b3727276_e6f9_12a7_bfa7_3faf14f08373["safe_not_equal"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> b3727276_e6f9_12a7_bfa7_3faf14f08373 bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> bde4209f_8ffc_1594_4024_b1835a44bcf6 14da5ffa_bc19_aee6_36b3_bbba24db7f02["deep_read_state"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> 14da5ffa_bc19_aee6_36b3_bbba24db7f02 a814b193_e12a_4037_c3c8_dfd45f3bd0bb["untrack"] 8a7e1359_80ee_d99b_c857_a4077af52e5a --> a814b193_e12a_4037_c3c8_dfd45f3bd0bb style 8a7e1359_80ee_d99b_c857_a4077af52e5a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { ActionPayload } from '#client' */
import { effect, render_effect } from '../../reactivity/effects.js';
import { safe_not_equal } from '../../reactivity/equality.js';
import { deep_read_state, untrack } from '../../runtime.js';
/**
* @template P
* @param {Element} dom
* @param {(dom: Element, value?: P) => ActionPayload<P>} action
* @param {() => P} [get_value]
* @returns {void}
*/
export function action(dom, action, get_value) {
effect(() => {
var payload = untrack(() => action(dom, get_value?.()) || {});
if (get_value && payload?.update) {
var inited = false;
/** @type {P} */
var prev = /** @type {any} */ ({}); // initialize with something so it's never equal on first run
render_effect(() => {
var value = get_value();
// Action's update method is coarse-grained, i.e. when anything in the passed value changes, update.
// This works in legacy mode because of mutable_source being updated as a whole, but when using $state
// together with actions and mutation, it wouldn't notice the change without a deep read.
deep_read_state(value);
if (inited && safe_not_equal(prev, value)) {
prev = value;
/** @type {Function} */ (payload.update)(value);
}
});
inited = true;
}
if (payload?.destroy) {
return () => /** @type {Function} */ (payload.destroy)();
}
});
}
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does actions.js do?
actions.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in actions.js?
actions.js defines 1 function(s): action.
What does actions.js depend on?
actions.js imports 8 module(s): deep_read_state, effect, effects.js, equality.js, render_effect, runtime.js, safe_not_equal, untrack.
Where is actions.js in the architecture?
actions.js is located at packages/svelte/src/internal/client/dom/elements/actions.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/elements).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free