Skip to content

Commit 4f78f64

Browse files
committed
fix
1 parent 085cdba commit 4f78f64

File tree

1 file changed

+12
-6
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+12
-6
lines changed

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,21 @@ export function render_effect(fn) {
349349
* @param {Array<() => any>} sync
350350
* @param {Array<() => Promise<any>>} async
351351
*/
352-
export async function template_effect(fn, sync = [], async = [], d = derived) {
353-
/** @type {Value[]} */
354-
const deriveds = sync.map(d);
355-
352+
export function template_effect(fn, sync = [], async = [], d = derived) {
356353
if (async.length > 0) {
357-
const async_deriveds = (await suspend(Promise.all(async.map(async_derived)))).exit();
358-
deriveds.push(...async_deriveds);
354+
suspend(Promise.all(async.map(async_derived))).then((result) => {
355+
create_template_effect(fn, [...sync.map(d), ...result.exit()]);
356+
});
357+
} else {
358+
create_template_effect(fn, sync.map(d));
359359
}
360+
}
360361

362+
/**
363+
* @param {(...expressions: any) => void | (() => void)} fn
364+
* @param {Value[]} deriveds
365+
*/
366+
function create_template_effect(fn, deriveds) {
361367
const effect = () => fn(...deriveds.map(get));
362368

363369
if (DEV) {

0 commit comments

Comments
 (0)