Home / Function/ with_root() — svelte Function Reference

with_root() — svelte Function Reference

Architecture documentation for the with_root() function in root.svelte.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  ecbf9a3c_a7d2_7b36_906f_e33b932a3711["with_root()"]
  26c2d9fa_2f22_f3f4_4437_a6f8408b9732["root.svelte.js"]
  ecbf9a3c_a7d2_7b36_906f_e33b932a3711 -->|defined in| 26c2d9fa_2f22_f3f4_4437_a6f8408b9732
  style ecbf9a3c_a7d2_7b36_906f_e33b932a3711 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/runtime-runes/samples/effect-root-3/root.svelte.js lines 1–20

export function with_root(get_x) {
	const cleanup = $effect.root(() => {
		$effect(() => {
			console.log(get_x());
		});

		const nested_cleanup = $effect.root(() => {
			return () => {
				console.log('cleanup 2');
			};
		});

		return () => {
			console.log('cleanup 1');
			nested_cleanup();
		};
	});

	return cleanup;
}

Domain

Subdomains

Frequently Asked Questions

What does with_root() do?
with_root() is a function in the svelte codebase, defined in packages/svelte/tests/runtime-runes/samples/effect-root-3/root.svelte.js.
Where is with_root() defined?
with_root() is defined in packages/svelte/tests/runtime-runes/samples/effect-root-3/root.svelte.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free