Home / File/ async.js — svelte Source File

async.js — svelte Source File

Architecture documentation for async.js, a javascript file in the svelte codebase. 22 imports, 6 dependents.

File javascript ClientRuntime Reactivity 22 imports 6 dependents 9 functions

Entity Profile

Dependency Diagram

graph LR
  1ad3e508_c069_abae_2e4a_bd17c8892e18["async.js"]
  48cf26f8_bf34_fd7a_3d52_cc963051e167["context.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 48cf26f8_bf34_fd7a_3d52_cc963051e167
  ad360ec3_c98b_ac47_212b_923d0363a0ce["is_runes"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> ad360ec3_c98b_ac47_212b_923d0363a0ce
  7a5dcc8e_a227_a041_3278_04368ddf1422["set_component_context"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 7a5dcc8e_a227_a041_3278_04368ddf1422
  0fccb27b_7aac_6445_e857_e807f2ce0d7d["set_dev_stack"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 0fccb27b_7aac_6445_e857_e807f2ce0d7d
  6d3d606a_fb7a_54af_1ece_f1eb12f174d1["boundary.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 6d3d606a_fb7a_54af_1ece_f1eb12f174d1
  2c67b85b_d904_f73c_3422_6086d51dc1d1["get_boundary"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 2c67b85b_d904_f73c_3422_6086d51dc1d1
  a502a1d2_db34_608a_1001_5401b198ec66["error-handling.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> a502a1d2_db34_608a_1001_5401b198ec66
  623c7d5f_8856_1cec_42aa_d58e310da5d1["invoke_error_boundary"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 623c7d5f_8856_1cec_42aa_d58e310da5d1
  bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> bde4209f_8ffc_1594_4024_b1835a44bcf6
  55623862_10b7_5361_e30b_34ec6941f1a7["set_active_effect"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 55623862_10b7_5361_e30b_34ec6941f1a7
  311ef9f4_9b68_c178_c1db_3b8696f7d964["set_active_reaction"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 311ef9f4_9b68_c178_c1db_3b8696f7d964
  d8e42d9d_2e3c_635c_19d3_b946a4341c0f["batch.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> d8e42d9d_2e3c_635c_19d3_b946a4341c0f
  517c145b_769f_b163_6854_d8f2a4412e11["Batch"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 517c145b_769f_b163_6854_d8f2a4412e11
  2fb8b3eb_7c25_3930_a184_09fab29d537f["deriveds.js"]
  1ad3e508_c069_abae_2e4a_bd17c8892e18 --> 2fb8b3eb_7c25_3930_a184_09fab29d537f
  style 1ad3e508_c069_abae_2e4a_bd17c8892e18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Blocker, Effect, Value } from '#client' */
import { DESTROYED, STALE_REACTION } from '#client/constants';
import { DEV } from 'esm-env';
import {
	component_context,
	dev_stack,
	is_runes,
	set_component_context,
	set_dev_stack
} from '../context.js';
import { get_boundary } from '../dom/blocks/boundary.js';
import { invoke_error_boundary } from '../error-handling.js';
import {
	active_effect,
	active_reaction,
	set_active_effect,
	set_active_reaction
} from '../runtime.js';
import { Batch, current_batch } from './batch.js';
import {
	async_derived,
	current_async_effect,
	derived,
	derived_safe_equal,
	set_from_async_derived
} from './deriveds.js';
import { aborted } from './effects.js';

/**
 * @param {Blocker[]} blockers
 * @param {Array<() => any>} sync
 * @param {Array<() => Promise<any>>} async
 * @param {(values: Value[]) => any} fn
 */
export function flatten(blockers, sync, async, fn) {
	const d = is_runes() ? derived : derived_safe_equal;

	// Filter out already-settled blockers - no need to wait for them
	var pending = blockers.filter((b) => !b.settled);

	if (async.length === 0 && pending.length === 0) {
		fn(sync.map(d));
		return;
	}

	var batch = current_batch;
	var parent = /** @type {Effect} */ (active_effect);

	var restore = capture();
	var blocker_promise =
		pending.length === 1
			? pending[0].promise
			: pending.length > 1
				? Promise.all(pending.map((b) => b.promise))
				: null;

	/** @param {Value[]} values */
	function finish(values) {
		restore();

// ... (243 more lines)

Domain

Subdomains

Frequently Asked Questions

What does async.js do?
async.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Reactivity subdomain.
What functions are defined in async.js?
async.js defines 9 function(s): capture, flatten, for_await_track_reactivity_loss, run, run_after_blockers, save, track_reactivity_loss, unset_context, wait.
What does async.js depend on?
async.js imports 22 module(s): Batch, aborted, async_derived, batch.js, boundary.js, constants, context.js, derived, and 14 more.
What files import async.js?
async.js is imported by 6 file(s): async.js, attributes.js, await.js, deriveds.js, effects.js, validate.js.
Where is async.js in the architecture?
async.js is located at packages/svelte/src/internal/client/reactivity/async.js (domain: ClientRuntime, subdomain: Reactivity, directory: packages/svelte/src/internal/client/reactivity).

Analyze Your Own Codebase

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

Try Supermodel Free