Dominic Gannaway 10 months ago
parent a4bf5e3981
commit e6cd4265eb

@ -192,4 +192,4 @@ export {
export { createRawSnippet } from './internal/client/dom/blocks/snippet.js';
export { suspend, unsuspend } from './internal/client/dom/blocks/boundary.js';
export { create_suspense } from './internal/client/dom/blocks/boundary.js';

@ -111,10 +111,13 @@ export function boundary(node, props, boundary_fn) {
suspend_count++;
if (suspended_effect === null) {
queue_micro_task(() => {
var effect = boundary_effect;
suspended_effect = boundary_effect;
pause_effect(suspended_effect, () => {
pause_effect(
suspended_effect,
() => {
/** @type {TemplateNode | null} */
var node = effect.nodes_start;
var end = effect.nodes_end;
@ -129,11 +132,14 @@ export function boundary(node, props, boundary_fn) {
suspended_fragment.append(node);
node = sibling;
}
}, false);
},
false
);
render_snippet(() => {
pending(anchor);
});
});
}
return true;
}
@ -211,13 +217,17 @@ export function boundary(node, props, boundary_fn) {
}
}
export function suspend() {
var current = active_effect;
/**
* @param {Effect | null} effect
* @param {typeof SUSPEND_INCREMENT | typeof SUSPEND_DECREMENT} trigger
*/
function trigger_suspense(effect, trigger) {
var current = effect;
while (current !== null) {
if ((current.f & BOUNDARY_EFFECT) !== 0) {
// @ts-ignore
if (current.fn(SUSPEND_INCREMENT)) {
if (current.fn(trigger)) {
return;
}
}
@ -225,16 +235,16 @@ export function suspend() {
}
}
export function unsuspend() {
export function create_suspense() {
var current = active_effect;
while (current !== null) {
if ((current.f & BOUNDARY_EFFECT) !== 0) {
// @ts-ignore
if (current.fn(SUSPEND_DECREMENT)) {
return;
}
}
current = current.parent;
}
const suspend = () => {
trigger_suspense(current, SUSPEND_INCREMENT);
};
const unsuspend = () => {
trigger_suspense(current, SUSPEND_DECREMENT);
};
return [suspend, unsuspend];
}

@ -129,7 +129,7 @@ export {
update_store,
mark_store_binding
} from './reactivity/store.js';
export { boundary, suspend } from './dom/blocks/boundary.js';
export { boundary } from './dom/blocks/boundary.js';
export { set_text } from './render.js';
export {
get,

Loading…
Cancel
Save