finish separation of suspend/capture

aaa
Rich Harris 8 months ago
parent 6b314bd202
commit 074afa9bec

@ -371,7 +371,11 @@ export function client_component(analysis, options) {
const body = b.function_declaration( const body = b.function_declaration(
b.id('$$body'), b.id('$$body'),
[b.id('$$anchor'), b.id('$$props')], [b.id('$$anchor'), b.id('$$props')],
b.block([...component_block.body, b.stmt(b.call('$.exit'))]) b.block([
b.var('$$unsuspend', b.call('$.suspend')),
...component_block.body,
b.stmt(b.call('$$unsuspend'))
])
); );
body.async = true; body.async = true;

@ -299,32 +299,11 @@ export function suspend() {
*/ */
export async function save(promise) { export async function save(promise) {
var restore = capture(); var restore = capture();
var value = await promise;
let boundary = active_effect;
while (boundary !== null) {
if ((boundary.f & BOUNDARY_EFFECT) !== 0) {
break;
}
boundary = boundary.parent;
}
if (boundary === null) {
e.await_outside_boundary();
}
// @ts-ignore
boundary?.fn(ASYNC_INCREMENT);
const value = await promise;
return { return {
restore() { restore() {
restore(); restore();
// @ts-ignore
boundary?.fn(ASYNC_DECREMENT);
return value; return value;
} }
}; };

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

Loading…
Cancel
Save