MCPcopy
hub / github.com/sveltejs/svelte / update_reaction

Function update_reaction

packages/svelte/src/internal/client/runtime.js:223–356  ·  view source on GitHub ↗
(reaction)

Source from the content-addressed store, hash-verified

221
222/** @param {Reaction} reaction */
223export function update_reaction(reaction) {
224 var previous_deps = new_deps;
225 var previous_skipped_deps = skipped_deps;
226 var previous_untracked_writes = untracked_writes;
227 var previous_reaction = active_reaction;
228 var previous_sources = current_sources;
229 var previous_component_context = component_context;
230 var previous_untracking = untracking;
231 var previous_update_version = update_version;
232
233 var flags = reaction.f;
234
235 new_deps = /** @type {null | Value[]} */ (null);
236 skipped_deps = 0;
237 untracked_writes = null;
238 active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
239
240 current_sources = null;
241 set_component_context(reaction.ctx);
242 untracking = false;
243 update_version = ++read_version;
244
245 if (reaction.ac !== null) {
246 without_reactive_context(() => {
247 /** @type {AbortController} */ (reaction.ac).abort(STALE_REACTION);
248 });
249
250 reaction.ac = null;
251 }
252
253 try {
254 reaction.f |= REACTION_IS_UPDATING;
255 var fn = /** @type {Function} */ (reaction.fn);
256 var result = fn();
257 reaction.f |= REACTION_RAN;
258 var deps = reaction.deps;
259
260 // Don't remove reactions during fork;
261 // they must remain for when fork is discarded
262 var is_fork = current_batch?.is_fork;
263
264 if (new_deps !== null) {
265 var i;
266
267 if (!is_fork) {
268 remove_reactions(reaction, skipped_deps);
269 }
270
271 if (deps !== null && skipped_deps > 0) {
272 deps.length = skipped_deps + new_deps.length;
273 for (i = 0; i < new_deps.length; i++) {
274 deps[skipped_deps + i] = new_deps[i];
275 }
276 } else {
277 reaction.deps = deps = new_deps;
278 }
279
280 if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {

Callers 2

execute_derivedFunction · 0.90
update_effectFunction · 0.85

Calls 10

set_component_contextFunction · 0.90
without_reactive_contextFunction · 0.90
effect_trackingFunction · 0.90
is_runesFunction · 0.90
handle_errorFunction · 0.90
remove_reactionsFunction · 0.85
abortMethod · 0.80
pushMethod · 0.80
fnFunction · 0.50

Tested by

no test coverage detected