out-of-order-rendering
Rich Harris 2 days ago
parent ed36dabaab
commit dd827a8a53

@ -255,12 +255,15 @@ function transform_body(program, context) {
if (statements.length > 0) { if (statements.length > 0) {
var declarations = statements.map((s) => s.declarations).flat(); var declarations = statements.map((s) => s.declarations).flat();
out.push(
b.declaration( if (declarations.length > 0) {
'var', out.push(
declarations.map((d) => b.declarator(d.node)) b.declaration(
) 'var',
); declarations.map((d) => b.declarator(d.node))
)
);
}
const thunks = statements.map((s) => { const thunks = statements.map((s) => {
if (s.node.type === 'VariableDeclarator') { if (s.node.type === 'VariableDeclarator') {

@ -276,9 +276,18 @@ export function run(thunks) {
let promise = Promise.resolve(); let promise = Promise.resolve();
return thunks.map((fn) => { var boundary = get_boundary();
var batch = /** @type {Batch} */ (current_batch);
var blocking = !boundary.is_pending();
boundary.update_pending_count(1);
batch.increment(blocking);
const promises = thunks.map((fn) => {
promise = promise promise = promise
.then(() => { .then(() => {
// TODO abort if component was destroyed
try { try {
restore(); restore();
return fn(); return fn();
@ -290,4 +299,11 @@ export function run(thunks) {
return promise; return promise;
}); });
promise.then(() => {
boundary.update_pending_count(-1);
batch.decrement(blocking);
});
return promises;
} }

Loading…
Cancel
Save