From 2325a5af52e414cf36eaa0a9ecaeb0041e87affc Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 3 Jul 2025 17:32:49 -0400 Subject: [PATCH] add a couple of comments --- .../src/internal/client/dom/blocks/boundary.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/svelte/src/internal/client/dom/blocks/boundary.js b/packages/svelte/src/internal/client/dom/blocks/boundary.js index e6dbc2a7d1..9212b3d5d4 100644 --- a/packages/svelte/src/internal/client/dom/blocks/boundary.js +++ b/packages/svelte/src/internal/client/dom/blocks/boundary.js @@ -380,6 +380,17 @@ export function get_pending_boundary() { return boundary; } +/** + * Captures the current effect context so that we can restore it after + * some asynchronous work has happened if `track` is true (so that e.g. + * `await a + b` causes `b` to be registered as a dependency). + * + * If `track` is false, we just take a note of which async derived + * brought us here, so that we can emit a `async_reactivity_loss` + * warning when it's appropriate to do so. + * + * @param {boolean} track + */ export function capture(track = true) { var previous_effect = active_effect; var previous_reaction = active_reaction; @@ -417,6 +428,9 @@ export function suspend() { } /** + * Wraps an `await` expression in such a way that the effect context that was + * active before the expression evaluated can be reapplied afterwards — + * `await a + b` becomes `(await $.save(a))() + b` * @template T * @param {Promise} promise * @param {boolean} [track]