pull/15844/head
Rich Harris 3 months ago
parent ea0e269138
commit 6b9f860b8e

@ -47,7 +47,7 @@ export function boundary(node, props, children) {
export class Boundary {
inert = false;
ran = false;
pending = false;
/** @type {Boundary | null} */
parent;
@ -96,6 +96,8 @@ export class Boundary {
this.parent = /** @type {Effect} */ (active_effect).b;
this.pending = !!this.#props.pending;
this.#effect = block(() => {
/** @type {Effect} */ (active_effect).b = this;
@ -124,7 +126,8 @@ export class Boundary {
pause_effect(/** @type {Effect} */ (this.#pending_effect), () => {
this.#pending_effect = null;
});
this.ran = true;
this.pending = false;
}
});
} else {
@ -137,7 +140,7 @@ export class Boundary {
if (this.#pending_count > 0) {
this.#show_pending_snippet();
} else {
this.ran = true;
this.pending = false;
}
}
}, flags);
@ -151,14 +154,6 @@ export class Boundary {
return !!this.#props.pending;
}
is_pending() {
if (!this.ran && this.#props.pending) {
return true;
}
return this.#pending_effect !== null && (this.#pending_effect.f & INERT) === 0;
}
/**
* @param {() => Effect | null} fn
*/
@ -201,7 +196,7 @@ export class Boundary {
}
commit() {
this.ran = true;
this.pending = false;
if (this.#pending_effect) {
pause_effect(this.#pending_effect, () => {
@ -244,7 +239,7 @@ export class Boundary {
});
}
this.ran = false;
this.pending = true;
this.#main_effect = this.#run(() => {
this.#is_creating_fallback = false;
@ -254,7 +249,7 @@ export class Boundary {
if (this.#pending_count > 0) {
this.#show_pending_snippet();
} else {
this.ran = true;
this.pending = false;
}
};

@ -132,10 +132,10 @@ export function async_derived(fn, location) {
prev = promise;
var batch = /** @type {Batch} */ (current_batch);
var ran = !boundary.is_pending();
var pending = boundary.pending;
if (should_suspend) {
(ran ? batch : boundary).increment();
(pending ? boundary : batch).increment();
}
/**
@ -148,10 +148,10 @@ export function async_derived(fn, location) {
from_async_derived = null;
if (should_suspend) {
(ran ? batch : boundary).decrement();
(pending ? boundary : batch).decrement();
}
if (ran) batch.restore();
if (!pending) batch.restore();
if (error) {
if (error !== STALE_REACTION) {
@ -179,7 +179,7 @@ export function async_derived(fn, location) {
}
}
if (ran) batch.flush();
if (!pending) batch.flush();
};
promise.then(handler, (e) => handler(null, e || 'unknown'));

@ -657,7 +657,7 @@ export function process_effects(batch, root) {
const boundary = effect.b;
if (check_dirtiness(effect)) {
var effects = boundary?.is_pending() ? batch.boundary_async_effects : batch.async_effects;
var effects = boundary?.pending ? batch.boundary_async_effects : batch.async_effects;
effects.push(effect);
}
} else if ((flags & BLOCK_EFFECT) !== 0) {

Loading…
Cancel
Save