tweak logic to make it clearer why and when we commit a batch

pull/15844/head
Rich Harris 3 months ago
parent 6b1ac77c87
commit c3aabc148a

@ -5,6 +5,7 @@ import {
flush_queued_effects,
flush_queued_root_effects,
process_effects,
queued_root_effects,
schedule_effect,
set_queued_root_effects,
set_signal_status,
@ -174,7 +175,7 @@ export class Batch {
this.render_effects = [];
this.effects = [];
this.commit();
this.#commit();
flush_queued_effects(render_effects);
flush_queued_effects(effects);
@ -227,7 +228,11 @@ export class Batch {
}
flush() {
if (queued_root_effects.length > 0) {
flush_queued_root_effects();
} else {
this.#commit();
}
if (current_batch !== this) {
// this can happen if a `flushSync` occurred during `flush_queued_root_effects`,
@ -242,7 +247,7 @@ export class Batch {
current_batch = null;
}
commit() {
#commit() {
for (const fn of this.#callbacks) {
fn();
}
@ -270,8 +275,6 @@ export class Batch {
this.render_effects = [];
this.effects = [];
this.commit();
}
}

@ -68,7 +68,7 @@ export function set_is_destroying_effect(value) {
// Handle effect queues
/** @type {Effect[]} */
let queued_root_effects = [];
export let queued_root_effects = [];
/** @param {Effect[]} v */
export function set_queued_root_effects(v) {

Loading…
Cancel
Save