incremental-batches
Rich Harris 1 month ago
parent 4bf3ad745f
commit 92ae2c3f88

@ -453,24 +453,28 @@ export class Batch {
* Associate a change to a given source with the current
* batch, noting its previous and current values
* @param {Value} source
* @param {any} old_value
* @param {any} value
*/
capture(source, old_value) {
if (old_value !== UNINITIALIZED && !this.previous.has(source)) {
this.previous.set(source, old_value);
capture(source, value) {
if (source.v !== UNINITIALIZED && !this.previous.has(source)) {
this.previous.set(source, source.v);
this.previous_wvs.set(source, source.wv);
}
// Don't save errors in `batch_values`, or they won't be thrown in `runtime.js#get`
if ((source.f & ERROR_VALUE) === 0) {
this.current.set(source, source.v);
batch_values?.set(source, source.v);
this.current.set(source, value);
batch_values?.set(source, value);
}
var version = increment_write_version();
source.wv = version;
this.wvs.set(source, version);
if (!this.is_fork) {
source.v = value;
source.wv = version;
}
}
/**

@ -204,9 +204,7 @@ export function internal_set(source, value, updated_during_traversal = null) {
derived.wv = write_version;
}
source.v = value;
batch.capture(source, old_value);
batch.capture(source, value);
if (DEV) {
if (tracing_mode_flag || active_effect !== null) {

Loading…
Cancel
Save