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

Function mark_reactions

packages/svelte/src/internal/client/reactivity/sources.js:337–393  ·  view source on GitHub ↗

* @param {Value} signal * @param {number} status should be DIRTY or MAYBE_DIRTY * @param {Effect[] | null} updated_during_traversal * @returns {void}

(signal, status, updated_during_traversal)

Source from the content-addressed store, hash-verified

335 * @returns {void}
336 */
337function mark_reactions(signal, status, updated_during_traversal) {
338 var reactions = signal.reactions;
339 if (reactions === null) return;
340
341 var runes = is_runes();
342 var length = reactions.length;
343
344 for (var i = 0; i < length; i++) {
345 var reaction = reactions[i];
346 var flags = reaction.f;
347
348 // In legacy mode, skip the current effect to prevent infinite loops
349 if (!runes && reaction === active_effect) continue;
350
351 var not_dirty = (flags & DIRTY) === 0;
352
353 // don't set a DIRTY reaction to MAYBE_DIRTY
354 if (not_dirty) {
355 set_signal_status(reaction, status);
356 }
357
358 if ((flags & EAGER_EFFECT) !== 0) {
359 // Eager effects need to run immediately:
360 // - for $inspect so that the stack trace makes sense
361 // - for $state.eager because they might be without an effect parent
362 eager_effects.add(/** @type {Effect} */ (reaction));
363 } else if ((flags & DERIVED) !== 0) {
364 var derived = /** @type {Derived} */ (reaction);
365
366 batch_values?.delete(derived);
367
368 if ((flags & WAS_MARKED) === 0) {
369 // Only connected deriveds being executed outside the update cycle can be reliably unmarked right away
370 if (
371 flags & CONNECTED &&
372 (active_effect === null || (active_effect.f & REACTION_IS_UPDATING) === 0)
373 ) {
374 reaction.f |= WAS_MARKED;
375 }
376
377 mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
378 }
379 } else if (not_dirty) {
380 var effect = /** @type {Effect} */ (reaction);
381
382 if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
383 eager_block_effects.add(effect);
384 }
385
386 if (updated_during_traversal !== null) {
387 updated_during_traversal.push(effect);
388 } else {
389 schedule_effect(effect);
390 }
391 }
392 }
393}

Callers 1

internal_setFunction · 0.85

Calls 6

is_runesFunction · 0.90
set_signal_statusFunction · 0.90
schedule_effectFunction · 0.90
pushMethod · 0.80
addMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected