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

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

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

Loading…
Cancel
Save