fix some stuff

blockless
Rich Harris 10 months ago
parent f7b194fb11
commit 4abd99fa9d

@ -65,34 +65,54 @@ export function await_block(anchor_node, get_input, pending_fn, then_fn, catch_f
if (then_fn) { if (then_fn) {
if (then_effect) { if (then_effect) {
resume_effect(then_effect); resume_effect(then_effect);
} else if (pending_fn) { } else if (then_fn) {
set_current_effect(branch); set_current_effect(branch);
then_effect = render_effect(() => then_fn(anchor_node, value), {}, true); then_effect = render_effect(() => then_fn(anchor_node, value), {}, true);
set_current_effect(null); set_current_effect(null);
} }
} }
}) })
.catch((error) => { .catch(() => {});
if (promise !== input) return;
promise.catch((error) => {
if (pending_effect) { if (promise !== input) return;
pause_effect(pending_effect, () => {
pending_effect = null; if (pending_effect) {
}); pause_effect(pending_effect, () => {
pending_effect = null;
});
}
if (catch_fn) {
if (catch_effect) {
resume_effect(catch_effect);
} else if (catch_fn) {
set_current_effect(branch);
catch_effect = render_effect(() => catch_fn(anchor_node, error), {}, true);
set_current_effect(null);
} }
}
});
} else {
if (pending_effect) {
pause_effect(pending_effect, () => {
pending_effect = null;
});
}
if (catch_fn) { if (then_effect) {
if (catch_effect) { resume_effect(then_effect);
resume_effect(catch_effect); } else if (then_fn) {
} else if (pending_fn) { // TODO we need to pass a function in rather than a value, because
set_current_effect(branch); // this will never update
catch_effect = render_effect(() => catch_fn(anchor_node, error), {}, true); then_effect = render_effect(() => then_fn(anchor_node, input), {}, true);
set_current_effect(null); }
}
} if (catch_effect) {
pause_effect(catch_effect, () => {
catch_effect = null;
}); });
} else { }
// TODO handle non-promises
} }
}); });

Loading…
Cancel
Save