remove props

async-fork
Dominic Gannaway 7 months ago
parent 3da337beea
commit bf39e3115d

@ -2,7 +2,7 @@
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import * as e from '../../../errors.js'; import * as e from '../../../errors.js';
const valid = ['onerror', 'failed', 'pending', 'showPendingAfter', 'showPendingFor']; const valid = ['onerror', 'failed', 'pending'];
/** /**
* @param {AST.SvelteBoundary} node * @param {AST.SvelteBoundary} node

@ -75,8 +75,6 @@ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
* onerror?: (error: unknown, reset: () => void) => void; * onerror?: (error: unknown, reset: () => void) => void;
* failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void; * failed?: (anchor: Node, error: () => unknown, reset: () => () => void) => void;
* pending?: (anchor: Node) => void; * pending?: (anchor: Node) => void;
* showPendingAfter?: number;
* showPendingFor?: number;
* }} props * }} props
* @param {((anchor: Node) => void)} children * @param {((anchor: Node) => void)} children
* @returns {void} * @returns {void}
@ -109,8 +107,6 @@ export function boundary(node, props, children) {
/** @type {Set<() => void>} */ /** @type {Set<() => void>} */
var callbacks = new Set(); var callbacks = new Set();
var keep_pending_snippet = false;
/** /**
* @param {() => void} snippet_fn * @param {() => void} snippet_fn
* @returns {Effect | null} * @returns {Effect | null}
@ -161,7 +157,7 @@ export function boundary(node, props, children) {
} }
function unsuspend() { function unsuspend() {
if (keep_pending_snippet || async_count > 0) { if (async_count > 0) {
return; return;
} }
@ -215,22 +211,7 @@ export function boundary(node, props, children) {
pending_effect = branch(() => pending(anchor)); pending_effect = branch(() => pending(anchor));
} }
// TODO do we want to differentiate between initial render and updates here? unsuspend();
if (!initial) {
keep_pending_snippet = true;
var end = raf.now() + (props.showPendingFor ?? 300);
loop((now) => {
if (now >= end) {
keep_pending_snippet = false;
unsuspend();
return false;
}
return true;
});
}
} else if (parent_boundary) { } else if (parent_boundary) {
throw new Error('TODO show pending snippet on parent'); throw new Error('TODO show pending snippet on parent');
} else { } else {
@ -241,19 +222,6 @@ export function boundary(node, props, children) {
// @ts-ignore We re-use the effect's fn property to avoid allocation of an additional field // @ts-ignore We re-use the effect's fn property to avoid allocation of an additional field
boundary.fn = (/** @type {unknown} */ input, /** @type {any} */ payload) => { boundary.fn = (/** @type {unknown} */ input, /** @type {any} */ payload) => {
if (input === ASYNC_INCREMENT) { if (input === ASYNC_INCREMENT) {
// post-init, show the pending snippet after a timeout
if ((boundary.f & BOUNDARY_SUSPENDED) === 0 && (boundary.f & EFFECT_RAN) !== 0) {
var start = raf.now();
var end = start + (props.showPendingAfter ?? 500);
loop((now) => {
if (async_count === 0) return false;
if (now < end) return true;
show_pending_snippet(false);
});
}
boundary.f |= BOUNDARY_SUSPENDED; boundary.f |= BOUNDARY_SUSPENDED;
async_count++; async_count++;
@ -263,7 +231,7 @@ export function boundary(node, props, children) {
} }
if (input === ASYNC_DECREMENT) { if (input === ASYNC_DECREMENT) {
if (--async_count === 0 && !keep_pending_snippet) { if (--async_count === 0) {
unsuspend(); unsuspend();
if (main_effect !== null) { if (main_effect !== null) {

Loading…
Cancel
Save