async-svelte-map
Rich Harris 7 months ago
parent db97c85769
commit 37d270b21f

@ -524,19 +524,46 @@ export class Batch {
} }
apply() { apply() {
if (!batches.has(this)) {
console.warn('wtf', this.id);
}
if (!async_mode_flag || (!this.is_fork && batches.size === 1)) return; if (!async_mode_flag || (!this.is_fork && batches.size === 1)) return;
console.log(this.id, batches.size);
// if there are multiple batches, we are 'time travelling' — // if there are multiple batches, we are 'time travelling' —
// we need to override values with the ones in this batch... // we need to override values with the ones in this batch...
batch_values = new Map(this.current); batch_values = new Map(this.current);
var is_earlier = true;
// ...and undo changes belonging to other batches // ...and undo changes belonging to other batches
// that don't coincide with this batch
for (const batch of batches) { for (const batch of batches) {
if (batch === this) continue; if (batch === this) {
is_earlier = false;
continue;
}
var coincides = false;
for (const [source, previous] of batch.previous) { if (is_earlier) {
if (!batch_values.has(source)) { for (const source of batch.current.keys()) {
batch_values.set(source, previous); if (this.current.has(source)) {
coincides = true;
break;
}
}
}
console.log(batch.id, { coincides });
if (!coincides) {
for (const [source, previous] of batch.previous) {
if (!batch_values.has(source)) {
batch_values.set(source, previous);
}
} }
} }
} }

Loading…
Cancel
Save