Home / Function/ hydratable() — svelte Function Reference

hydratable() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  aceb9558_4599_fbdb_f0c7_8abf2fb32324["hydratable()"]
  2d51c6c9_d3dc_2c19_12a2_18adb2ef1c08["hydratable.js"]
  aceb9558_4599_fbdb_f0c7_8abf2fb32324 -->|defined in| 2d51c6c9_d3dc_2c19_12a2_18adb2ef1c08
  996c7fa5_2d99_0bb8_8ca5_ceef284d88cf["get_render_context()"]
  aceb9558_4599_fbdb_f0c7_8abf2fb32324 -->|calls| 996c7fa5_2d99_0bb8_8ca5_ceef284d88cf
  3af20123_9b35_859d_7355_a5f03f994226["compare()"]
  aceb9558_4599_fbdb_f0c7_8abf2fb32324 -->|calls| 3af20123_9b35_859d_7355_a5f03f994226
  f0cff7bd_d799_b072_8f02_3d0ffad0caa8["encode()"]
  aceb9558_4599_fbdb_f0c7_8abf2fb32324 -->|calls| f0cff7bd_d799_b072_8f02_3d0ffad0caa8
  style aceb9558_4599_fbdb_f0c7_8abf2fb32324 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/server/hydratable.js lines 16–41

export function hydratable(key, fn) {
	if (!async_mode_flag) {
		e.experimental_async_required('hydratable');
	}

	const { hydratable } = get_render_context();

	let entry = hydratable.lookup.get(key);

	if (entry !== undefined) {
		if (DEV) {
			const comparison = compare(key, entry, encode(key, fn()));
			comparison.catch(() => {});
			hydratable.comparisons.push(comparison);
		}

		return /** @type {T} */ (entry.value);
	}

	const value = fn();

	entry = encode(key, value, hydratable.unresolved_promises);
	hydratable.lookup.set(key, entry);

	return value;
}

Domain

Subdomains

Frequently Asked Questions

What does hydratable() do?
hydratable() is a function in the svelte codebase, defined in packages/svelte/src/internal/server/hydratable.js.
Where is hydratable() defined?
hydratable() is defined in packages/svelte/src/internal/server/hydratable.js at line 16.
What does hydratable() call?
hydratable() calls 3 function(s): compare, encode, get_render_context.

Analyze Your Own Codebase

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

Try Supermodel Free