async-changeset
Rich Harris 7 months ago
parent 4a9ff233cd
commit 6b058526f3

@ -23,7 +23,6 @@ export const EFFECT_PRESERVED = 1 << 21; // effects with this flag should not be
// Flags used for async
export const REACTION_IS_UPDATING = 1 << 22;
export const BOUNDARY_SUSPENDED = 1 << 23;
export const STATE_SYMBOL = Symbol('$state');
export const STATE_SYMBOL_METADATA = Symbol('$state metadata');

@ -2,7 +2,6 @@
import {
BOUNDARY_EFFECT,
BOUNDARY_SUSPENDED,
EFFECT_PRESERVED,
EFFECT_RAN,
EFFECT_TRANSPARENT,
@ -56,6 +55,8 @@ export function set_active_boundary(boundary) {
*/
export class Boundary {
suspended = false;
/** @type {TemplateNode} */
#anchor;
@ -111,10 +112,7 @@ export class Boundary {
const reset = () => {
this.#pending_count = 0;
if ((this.#effect.f & BOUNDARY_SUSPENDED) !== 0) {
this.#effect.f ^= BOUNDARY_SUSPENDED;
}
this.suspended = false;
if (this.#failed_effect !== null) {
pause_effect(this.#failed_effect, () => {
@ -133,7 +131,7 @@ export class Boundary {
});
if (this.#pending_count > 0) {
this.#effect.f |= BOUNDARY_SUSPENDED;
this.suspended = true;
this.#show_pending_snippet(true);
}
};
@ -142,10 +140,7 @@ export class Boundary {
boundary_effect.fn = (/** @type {unknown} */ input, /** @type {any} */ payload) => {
if (input === ASYNC_INCREMENT) {
// post-init, show the pending snippet after a timeout
if (
(boundary_effect.f & BOUNDARY_SUSPENDED) === 0 &&
(boundary_effect.f & EFFECT_RAN) !== 0
) {
if (!this.suspended && (boundary_effect.f & EFFECT_RAN) !== 0) {
var start = raf.now();
var end = start + (this.#props.showPendingAfter ?? 500);
@ -157,7 +152,7 @@ export class Boundary {
});
}
boundary_effect.f |= BOUNDARY_SUSPENDED;
this.suspended = true;
this.#pending_count++;
return;
@ -266,7 +261,7 @@ export class Boundary {
this.#main_effect = branch(() => children(this.#anchor));
if (this.#pending_count > 0) {
boundary_effect.f |= BOUNDARY_SUSPENDED;
this.suspended = true;
this.#show_pending_snippet(true);
}
}
@ -363,9 +358,7 @@ export class Boundary {
return;
}
if ((this.#effect.f & BOUNDARY_SUSPENDED) !== 0) {
this.#effect.f ^= BOUNDARY_SUSPENDED;
}
this.suspended = false;
for (const e of this.#render_effects) {
try {

@ -24,8 +24,7 @@ import {
LEGACY_DERIVED_PROP,
DISCONNECTED,
BOUNDARY_EFFECT,
REACTION_IS_UPDATING,
BOUNDARY_SUSPENDED
REACTION_IS_UPDATING
} from './constants.js';
import {
flush_idle_tasks,
@ -835,7 +834,7 @@ function process_effects(effect, collected_effects, boundary) {
process_effects(current_effect, collected_effects, b);
if ((current_effect.f & BOUNDARY_SUSPENDED) === 0) {
if (!b.suspended) {
// no more async work to happen
b.commit();
}

Loading…
Cancel
Save