pull/15844/head
Rich Harris 3 months ago
parent 3eee9d5f9d
commit 7d6b60391e

@ -67,13 +67,15 @@ export function RenderTag(node, context) {
);
}
if (memoizer.async.length > 0) {
const async_values = memoizer.async_values();
if (async_values) {
context.state.init.push(
b.stmt(
b.call(
'$.async',
context.state.node,
b.array(memoizer.async.map((memo) => b.thunk(memo.expression, true))),
memoizer.async_values(),
b.arrow(
[context.state.node, ...memoizer.async.map((memo) => memo.id)],
b.block(statements)

@ -76,13 +76,15 @@ export function SlotElement(node, context) {
b.stmt(b.call('$.slot', context.state.node, b.id('$$props'), name, props_expression, fallback))
);
if (memoizer.async.length > 0) {
const async_values = memoizer.async_values();
if (async_values) {
context.state.init.push(
b.stmt(
b.call(
'$.async',
context.state.node,
b.array(memoizer.async.map((memo) => b.thunk(memo.expression, true))),
async_values,
b.arrow(
[context.state.node, ...memoizer.async.map((memo) => memo.id)],
b.block(statements)

@ -501,12 +501,14 @@ export function build_component(node, component_name, context) {
memoizer.apply();
if (memoizer.async.length > 0) {
const async_values = memoizer.async_values();
if (async_values) {
return b.stmt(
b.call(
'$.async',
anchor,
b.array(memoizer.async.map(({ expression }) => b.thunk(expression, true))),
async_values,
b.arrow([b.id('$$anchor'), ...memoizer.async.map(({ id }) => id)], b.block(statements))
)
);

@ -91,8 +91,7 @@ export function build_attribute_effect(
),
memoizer.sync.length > 0 &&
b.array(memoizer.sync.map(({ expression }) => b.thunk(expression))),
memoizer.async.length > 0 &&
b.array(memoizer.async.map(({ expression }) => b.thunk(expression, true))),
memoizer.async_values(),
element.metadata.scoped &&
context.state.analysis.css.hash !== '' &&
b.literal(context.state.analysis.css.hash),

@ -38,6 +38,11 @@ export class Memoizer {
return all;
}
async_values() {
if (this.async.length === 0) return;
return b.array(this.async.map((memo) => b.thunk(memo.expression, true)));
}
}
/**
@ -155,8 +160,7 @@ export function build_render_statement(state) {
: b.block(state.update)
),
all.length > 0 && b.array(memoizer.sync.map(({ expression }) => b.thunk(expression))),
memoizer.async.length > 0 &&
b.array(memoizer.async.map(({ expression }) => b.thunk(expression, true)))
memoizer.async_values()
)
);
}

Loading…
Cancel
Save