re-run blocks on subsequent flushes

pull/15844/head
Rich Harris 2 months ago
parent 7a43163fff
commit 7d853cf27b

@ -124,6 +124,13 @@ export class Batch {
*/ */
#effects = []; #effects = [];
/**
* Block effects, which may need to re-run on subsequent flushes
* in order to update internal sources (e.g. each block items)
* @type {Effect[]}
*/
#block_effects = [];
/** /**
* A set of branches that still exist, but will be destroyed when this batch * A set of branches that still exist, but will be destroyed when this batch
* is committed we skip over these during `process` * is committed we skip over these during `process`
@ -177,6 +184,7 @@ export class Batch {
this.#render_effects = []; this.#render_effects = [];
this.#effects = []; this.#effects = [];
this.#block_effects = [];
this.#commit(); this.#commit();
@ -188,6 +196,7 @@ export class Batch {
// otherwise mark effects clean so they get scheduled on the next run // otherwise mark effects clean so they get scheduled on the next run
for (const e of this.#render_effects) set_signal_status(e, CLEAN); for (const e of this.#render_effects) set_signal_status(e, CLEAN);
for (const e of this.#effects) set_signal_status(e, CLEAN); for (const e of this.#effects) set_signal_status(e, CLEAN);
for (const e of this.#block_effects) set_signal_status(e, CLEAN);
} }
if (current_values) { if (current_values) {
@ -243,6 +252,7 @@ export class Batch {
var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects; var effects = effect.b?.pending ? this.#boundary_async_effects : this.#async_effects;
effects.push(effect); effects.push(effect);
} else { } else {
if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
update_effect(effect); update_effect(effect);
} }
} }
@ -367,6 +377,11 @@ export class Batch {
schedule_effect(e); schedule_effect(e);
} }
for (const e of this.#block_effects) {
set_signal_status(e, DIRTY);
schedule_effect(e);
}
this.#render_effects = []; this.#render_effects = [];
this.#effects = []; this.#effects = [];

Loading…
Cancel
Save