pull/15844/head
Rich Harris 2 months ago
parent a7e0c84782
commit 8f47fa8119

@ -17,35 +17,35 @@ import { async_derived, derived, derived_safe_equal } from './deriveds.js';
export function flatten(sync, async, fn) {
const d = is_runes() ? derived : derived_safe_equal;
if (async.length > 0) {
var batch = current_batch;
var parent = /** @type {Effect} */ (active_effect);
if (async.length === 0) {
fn(sync.map(d));
return;
}
var restore = capture();
var batch = current_batch;
var parent = /** @type {Effect} */ (active_effect);
var boundary = get_pending_boundary();
var restore = capture();
var boundary = get_pending_boundary();
Promise.all(async.map((expression) => async_derived(expression)))
.then((result) => {
batch?.activate();
Promise.all(async.map((expression) => async_derived(expression)))
.then((result) => {
batch?.activate();
restore();
restore();
try {
fn([...sync.map(d), ...result]);
} catch (error) {
// ignore errors in blocks that have already been destroyed
if ((parent.f & DESTROYED) === 0) {
invoke_error_boundary(error, parent);
}
try {
fn([...sync.map(d), ...result]);
} catch (error) {
// ignore errors in blocks that have already been destroyed
if ((parent.f & DESTROYED) === 0) {
invoke_error_boundary(error, parent);
}
}
batch?.deactivate();
})
.catch((error) => {
boundary.error(error);
});
} else {
fn(sync.map(d));
}
batch?.deactivate();
})
.catch((error) => {
boundary.error(error);
});
}

Loading…
Cancel
Save