MCPcopy
hub / github.com/sveltejs/svelte / #run

Method #run

packages/svelte/src/internal/client/dom/blocks/boundary.js:302–322  ·  view source on GitHub ↗

* @template T * @param {() => T} fn

(fn)

Source from the content-addressed store, hash-verified

300 * @param {() => T} fn
301 */
302 #run(fn) {
303 var previous_effect = active_effect;
304 var previous_reaction = active_reaction;
305 var previous_ctx = component_context;
306
307 set_active_effect(this.#effect);
308 set_active_reaction(this.#effect);
309 set_component_context(this.#effect.ctx);
310
311 try {
312 Batch.ensure();
313 return fn();
314 } catch (e) {
315 handle_error(e);
316 return null;
317 } finally {
318 set_active_effect(previous_effect);
319 set_active_reaction(previous_reaction);
320 set_component_context(previous_ctx);
321 }
322 }
323
324 /**
325 * Updates the pending count associated with the currently visible pending snippet,

Callers 3

resetMethod · 0.95
handle_error_resultMethod · 0.95

Calls 6

set_active_effectFunction · 0.90
set_active_reactionFunction · 0.90
set_component_contextFunction · 0.90
handle_errorFunction · 0.90
fnFunction · 0.50
ensureMethod · 0.45

Tested by

no test coverage detected