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

Function get

packages/svelte/src/internal/client/runtime.js:527–697  ·  view source on GitHub ↗
(signal)

Source from the content-addressed store, hash-verified

525 * @returns {V}
526 */
527export function get(signal) {
528 var flags = signal.f;
529 var is_derived = (flags & DERIVED) !== 0;
530
531 captured_signals?.add(signal);
532
533 // Register the dependency on the current reaction signal.
534 if (active_reaction !== null && !untracking) {
535 // if we're in a derived that is being read inside an _async_ derived,
536 // it's possible that the effect was already destroyed. In this case,
537 // we don't add the dependency, because that would create a memory leak
538 var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
539
540 if (!destroyed && (current_sources === null || !current_sources.has(signal))) {
541 var deps = active_reaction.deps;
542
543 if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
544 // we're in the effect init/update cycle
545 if (signal.rv < read_version) {
546 signal.rv = read_version;
547
548 // If the signal is accessing the same dependencies in the same
549 // order as it did last time, increment `skipped_deps`
550 // rather than updating `new_deps`, which creates GC cost
551 if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
552 skipped_deps++;
553 } else if (new_deps === null) {
554 new_deps = [signal];
555 } else {
556 new_deps.push(signal);
557 }
558 }
559 } else {
560 // We're adding a dependency outside the init/update cycle (i.e. after an `await`).
561 // We have to deduplicate deps/reactions in this case or remove_reactions could
562 // disconnect deps/reactions that are actually still in use (if skip_deps says
563 // "disconnect all after this index" and some of the signals are also present in
564 // list prior to the cutoff index, i.e. that should be kept).
565 active_reaction.deps ??= [];
566 if (!includes.call(active_reaction.deps, signal)) {
567 active_reaction.deps.push(signal);
568 }
569
570 var reactions = signal.reactions;
571
572 if (reactions === null) {
573 signal.reactions = [active_reaction];
574 } else if (!includes.call(reactions, active_reaction)) {
575 reactions.push(active_reaction);
576 }
577 }
578 }
579 }
580
581 if (DEV) {
582 if (
583 !untracking &&
584 reactivity_loss_tracker &&

Callers 1

safe_getFunction · 0.70

Calls 13

get_errorFunction · 0.90
execute_derivedFunction · 0.90
update_derivedFunction · 0.90
unfreeze_derived_effectsFunction · 0.90
depends_on_old_valuesFunction · 0.85
is_dirtyFunction · 0.85
reconnectFunction · 0.85
pushMethod · 0.80
setMethod · 0.65
addMethod · 0.45
hasMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected