Dominic Gannaway 8 months ago
parent 5f5375a3f1
commit fae03532b8

@ -18,7 +18,7 @@ export function AwaitExpression(node, context) {
b.await( b.await(
b.call( b.call(
'$.suspend', '$.suspend',
node.argument && b.thunk(/** @type {Expression} */ (context.visit(node.argument))) node.argument && /** @type {Expression} */ (context.visit(node.argument))
) )
), ),
'exit' 'exit'

@ -266,10 +266,10 @@ export function trigger_async_boundary(effect, trigger) {
/** /**
* @template T * @template T
* @param {() => Promise<T> | Promise<T>} input * @param {Promise<T>} promise
* @returns {Promise<{ exit: () => T }>} * @returns {Promise<{ exit: () => T }>}
*/ */
export async function suspend(input) { export async function suspend(promise) {
var previous_effect = active_effect; var previous_effect = active_effect;
var previous_reaction = active_reaction; var previous_reaction = active_reaction;
var previous_component_context = component_context; var previous_component_context = component_context;
@ -290,12 +290,6 @@ export async function suspend(input) {
// @ts-ignore // @ts-ignore
boundary?.fn(ASYNC_INCREMENT); boundary?.fn(ASYNC_INCREMENT);
const promise = typeof input === 'function' ? input() : input;
// Ensure we reset the context back so it doesn't leak
set_active_effect(previous_effect);
set_active_reaction(previous_reaction);
set_component_context(previous_component_context);
const value = await promise; const value = await promise;
return { return {

Loading…
Cancel
Save