|
|
@ -1,8 +1,5 @@
|
|
|
|
/** @import { Effect, TemplateNode, Value } from '#client' */
|
|
|
|
/** @import { TemplateNode, Value } from '#client' */
|
|
|
|
/** @import { Batch } from '../../reactivity/batch.js' */
|
|
|
|
|
|
|
|
import { async_derived } from '../../reactivity/deriveds.js';
|
|
|
|
import { async_derived } from '../../reactivity/deriveds.js';
|
|
|
|
import { current_batch } from '../../reactivity/batch.js';
|
|
|
|
|
|
|
|
import { active_effect, schedule_effect } from '../../runtime.js';
|
|
|
|
|
|
|
|
import { capture, get_pending_boundary } from './boundary.js';
|
|
|
|
import { capture, get_pending_boundary } from './boundary.js';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -13,26 +10,15 @@ import { capture, get_pending_boundary } from './boundary.js';
|
|
|
|
export function async(node, expressions, fn) {
|
|
|
|
export function async(node, expressions, fn) {
|
|
|
|
// TODO handle hydration
|
|
|
|
// TODO handle hydration
|
|
|
|
|
|
|
|
|
|
|
|
var batch = /** @type {Batch} */ (current_batch);
|
|
|
|
|
|
|
|
var effect = /** @type {Effect} */ (active_effect);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var boundary = get_pending_boundary(effect);
|
|
|
|
|
|
|
|
var ran = boundary.ran;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var restore = capture();
|
|
|
|
var restore = capture();
|
|
|
|
|
|
|
|
var boundary = get_pending_boundary();
|
|
|
|
|
|
|
|
|
|
|
|
boundary.increment();
|
|
|
|
boundary.increment();
|
|
|
|
|
|
|
|
|
|
|
|
Promise.all(expressions.map((fn) => async_derived(fn))).then((result) => {
|
|
|
|
Promise.all(expressions.map((fn) => async_derived(fn))).then((result) => {
|
|
|
|
if (ran) batch.restore();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
restore();
|
|
|
|
restore();
|
|
|
|
fn(node, ...result);
|
|
|
|
fn(node, ...result);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO is this necessary?
|
|
|
|
|
|
|
|
schedule_effect(effect);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ran) batch.flush();
|
|
|
|
|
|
|
|
boundary.decrement();
|
|
|
|
boundary.decrement();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|