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

Method capture

packages/svelte/src/internal/client/reactivity/batch.js:578–592  ·  view source on GitHub ↗

* Associate a change to a given source with the current * batch, noting its previous and current values * @param {Value} source * @param {any} value * @param {boolean} [is_derived]

(source, value, is_derived = false)

Source from the content-addressed store, hash-verified

576 * @param {boolean} [is_derived]
577 */
578 capture(source, value, is_derived = false) {
579 if (source.v !== UNINITIALIZED && !this.previous.has(source)) {
580 this.previous.set(source, source.v);
581 }
582
583 // Don't save errors in `batch_values`, or they won't be thrown in `runtime.js#get`
584 if ((source.f & ERROR_VALUE) === 0) {
585 this.current.set(source, [value, is_derived]);
586 batch_values?.set(source, value);
587 }
588
589 if (!this.is_fork) {
590 source.v = value;
591 }
592 }
593
594 activate() {
595 current_batch = this;

Callers 2

internal_setFunction · 0.80
update_derivedFunction · 0.80

Calls 2

setMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected