Home / Function/ get() — svelte Function Reference

get() — svelte Function Reference

Architecture documentation for the get() function in runtime.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  a08b6cc5_af73_1be4_d02f_3113cf8a8305["get()"]
  bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"]
  a08b6cc5_af73_1be4_d02f_3113cf8a8305 -->|defined in| bde4209f_8ffc_1594_4024_b1835a44bcf6
  efa000ed_5584_e5fe_e342_766e8a0ac7e0["getContext()"]
  efa000ed_5584_e5fe_e342_766e8a0ac7e0 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  3d4087a1_f844_f105_4e79_f5f1a65e1203["hmr()"]
  3d4087a1_f844_f105_4e79_f5f1a65e1203 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  4de7f5ce_83b2_1bef_8e42_34d4dcb4c29f["async()"]
  4de7f5ce_83b2_1bef_8e42_34d4dcb4c29f -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  ecf3ff80_c7be_01cc_bbc7_3315415e7fe1["get_effect_pending()"]
  ecf3ff80_c7be_01cc_bbc7_3315415e7fe1 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  7f76e82e_4ed8_1525_9136_2ae67868d44e["each()"]
  7f76e82e_4ed8_1525_9136_2ae67868d44e -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  3ceb9b1c_7062_d75e_744a_fd12a80dfdc9["reconcile()"]
  3ceb9b1c_7062_d75e_744a_fd12a80dfdc9 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  f01b2d36_2cbe_16dc_aaec_1074483ccca8["validate_each_keys()"]
  f01b2d36_2cbe_16dc_aaec_1074483ccca8 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  0c0569a6_0fe6_ad48_18b5_235d70e8fd1f["set_custom_element_data()"]
  0c0569a6_0fe6_ad48_18b5_235d70e8fd1f -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  1d3fa733_c8b9_7ca3_c600_2689a6e7c29d["get_setters()"]
  1d3fa733_c8b9_7ca3_c600_2689a6e7c29d -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  5c05338d_77e4_261b_050c_69794590bc6f["bind_value()"]
  5c05338d_77e4_261b_050c_69794590bc6f -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  af7a3d2c_ef51_8bd4_b88c_e1d52a36db1e["bind_group()"]
  af7a3d2c_ef51_8bd4_b88c_e1d52a36db1e -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  4893ee4c_1b9f_f395_a7f3_99d313f8d608["bind_checked()"]
  4893ee4c_1b9f_f395_a7f3_99d313f8d608 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  c1821138_7138_0a8c_b42b_7fbee45e91b9["bind_files()"]
  c1821138_7138_0a8c_b42b_7fbee45e91b9 -->|calls| a08b6cc5_af73_1be4_d02f_3113cf8a8305
  style a08b6cc5_af73_1be4_d02f_3113cf8a8305 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/client/runtime.js lines 516–672

export function get(signal) {
	var flags = signal.f;
	var is_derived = (flags & DERIVED) !== 0;

	captured_signals?.add(signal);

	// Register the dependency on the current reaction signal.
	if (active_reaction !== null && !untracking) {
		// if we're in a derived that is being read inside an _async_ derived,
		// it's possible that the effect was already destroyed. In this case,
		// we don't add the dependency, because that would create a memory leak
		var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;

		if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
			var deps = active_reaction.deps;

			if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
				// we're in the effect init/update cycle
				if (signal.rv < read_version) {
					signal.rv = read_version;

					// If the signal is accessing the same dependencies in the same
					// order as it did last time, increment `skipped_deps`
					// rather than updating `new_deps`, which creates GC cost
					if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
						skipped_deps++;
					} else if (new_deps === null) {
						new_deps = [signal];
					} else {
						new_deps.push(signal);
					}
				}
			} else {
				// we're adding a dependency outside the init/update cycle
				// (i.e. after an `await`)
				(active_reaction.deps ??= []).push(signal);

				var reactions = signal.reactions;

				if (reactions === null) {
					signal.reactions = [active_reaction];
				} else if (!includes.call(reactions, active_reaction)) {
					reactions.push(active_reaction);
				}
			}
		}
	}

	if (DEV) {
		// TODO reinstate this, but make it actually work
		// if (current_async_effect) {
		// 	var tracking = (current_async_effect.f & REACTION_IS_UPDATING) !== 0;
		// 	var was_read = current_async_effect.deps?.includes(signal);

		// 	if (!tracking && !untracking && !was_read) {
		// 		w.await_reactivity_loss(/** @type {string} */ (signal.label));

		// 		var trace = get_error('traced at');
		// 		// eslint-disable-next-line no-console
		// 		if (trace) console.warn(trace);
		// 	}
		// }

		recent_async_deriveds.delete(signal);

		if (
			tracing_mode_flag &&
			!untracking &&
			tracing_expressions !== null &&
			active_reaction !== null &&
			tracing_expressions.reaction === active_reaction
		) {
			// Used when mapping state between special blocks like `each`
			if (signal.trace) {
				signal.trace();
			} else {
				var trace = get_error('traced at');

				if (trace) {
					var entry = tracing_expressions.entries.get(signal);

Domain

Subdomains

Frequently Asked Questions

What does get() do?
get() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/runtime.js.
Where is get() defined?
get() is defined in packages/svelte/src/internal/client/runtime.js at line 516.
What does get() call?
get() calls 9 function(s): depends_on_old_values, execute_derived, get_error, is_dirty, push, reconnect, set, trace, and 1 more.
What calls get()?
get() is called by 72 function(s): ResizeObserver, _mount, apply_adjustments, async, async_derived, batches, bind_checked, bind_files, and 64 more.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free