pull/16197/head
Rich Harris 8 months ago
parent 14330bd770
commit f77df36ff1

@ -140,7 +140,7 @@ export class Boundary {
// the pending or main block was rendered for a given
// boundary, and hydrate accordingly
queueMicrotask(() => {
destroy_effect(/** @type {Effect} */ (this.#pending_effect));
// destroy_effect(/** @type {Effect} */ (this.#pending_effect));
this.#main_effect = this.#run(() => {
return branch(() => this.#children(this.#anchor));

@ -105,6 +105,12 @@ export function async_derived(fn, location) {
// only suspend in async deriveds created on initialisation
var should_suspend = !active_reaction;
var boundary = /** @type {Effect} */ (active_effect).b;
while (boundary !== null && !boundary.has_pending_snippet()) {
boundary = boundary.parent;
}
render_effect(() => {
if (DEV) from_async_derived = active_effect;
promise = fn();
@ -115,8 +121,16 @@ export function async_derived(fn, location) {
var fork = active_fork;
if (should_suspend) {
// TODO if nearest pending boundary is not ready, attach to the boundary
fork?.increment();
if (fork !== null) {
fork.increment();
} else {
if (boundary === null) {
throw new Error('TODO');
}
// if nearest pending boundary is not ready, attach to the boundary
boundary.increment();
}
}
promise.then(
@ -129,7 +143,15 @@ export function async_derived(fn, location) {
from_async_derived = null;
if (should_suspend) {
fork?.decrement();
if (fork !== null) {
fork.decrement();
} else {
if (boundary === null) {
throw new Error('TODO');
}
boundary.decrement();
}
}
if (fork !== null) {

@ -26,6 +26,7 @@ export default test({
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
await Promise.resolve();
flushSync();
await tick();
assert.htmlEqual(target.innerHTML, '<p>42</p>');

Loading…
Cancel
Save