pull/15844/head
Rich Harris 2 months ago
parent eaf4d0d808
commit c2e6b28a55

@ -304,7 +304,7 @@ export class Batch {
flush() { flush() {
if (queued_root_effects.length > 0) { if (queued_root_effects.length > 0) {
this.flush_effects(); this.flush_effects();
} else if (!this.#neutered) { } else {
this.#commit(); this.#commit();
} }
@ -352,8 +352,10 @@ export class Batch {
* Append and remove branches to/from the DOM * Append and remove branches to/from the DOM
*/ */
#commit() { #commit() {
for (const fn of this.#callbacks) { if (!this.#neutered) {
fn(); for (const fn of this.#callbacks) {
fn();
}
} }
this.#callbacks.clear(); this.#callbacks.clear();

@ -146,10 +146,6 @@ export function async_derived(fn, location) {
const handler = (value, error = undefined) => { const handler = (value, error = undefined) => {
prev = null; prev = null;
if ((parent.f & DESTROYED) !== 0) {
batch.neuter();
}
current_async_effect = null; current_async_effect = null;
if (!pending) batch.activate(); if (!pending) batch.activate();
@ -187,6 +183,12 @@ export function async_derived(fn, location) {
}; };
promise.then(handler, (e) => handler(null, e || 'unknown')); promise.then(handler, (e) => handler(null, e || 'unknown'));
if (batch) {
return () => {
queueMicrotask(() => batch.neuter());
};
}
}); });
if (DEV) { if (DEV) {

Loading…
Cancel
Save