merge-batches
Rich Harris 1 day ago
parent cb6e8244ae
commit ecdfd5b40c

@ -350,8 +350,6 @@ export class Batch {
this.#callbacks.clear(); this.#callbacks.clear();
if (batches.size > 1) { if (batches.size > 1) {
const effects = new Set();
/** /**
* @param {Value} value * @param {Value} value
* @param {Set<Effect>} effects * @param {Set<Effect>} effects
@ -370,24 +368,32 @@ export class Batch {
} }
}; };
for (const source of this.current.keys()) {
// TODO do we also need block effects?
get_async_effects(source, effects);
}
this.#previous.clear(); this.#previous.clear();
let is_earlier = true;
for (const batch of batches) { for (const batch of batches) {
if (batch === this) { if (batch === this) {
is_earlier = true;
continue; continue;
} }
current_batch = batch; const effects = new Set();
const revert = Batch.apply(batch);
for (const e of effects) { for (const source of this.current.keys()) {
update_effect(e); if (is_earlier && batch.current.has(source)) continue;
// TODO do we also need block effects?
get_async_effects(source, effects);
}
if (effects.size > 0) {
current_batch = batch;
const revert = Batch.apply(batch);
for (const e of effects) {
update_effect(e);
}
revert();
} }
revert();
} }
current_batch = null; current_batch = null;

Loading…
Cancel
Save