pull/16197/head
Rich Harris 6 months ago
parent b48c12b859
commit e247f665af

@ -24,6 +24,7 @@ import { queue_boundary_micro_task } from '../task.js';
import * as e from '../../../shared/errors.js'; import * as e from '../../../shared/errors.js';
import { DEV } from 'esm-env'; import { DEV } from 'esm-env';
import { from_async_derived, set_from_async_derived } from '../../reactivity/deriveds.js'; import { from_async_derived, set_from_async_derived } from '../../reactivity/deriveds.js';
import { active_fork, Fork } from '../../reactivity/forks.js';
/** /**
* @typedef {{ * @typedef {{
@ -114,6 +115,7 @@ export class Boundary {
// boundary, and hydrate accordingly // boundary, and hydrate accordingly
queueMicrotask(() => { queueMicrotask(() => {
this.#main_effect = this.#run(() => { this.#main_effect = this.#run(() => {
Fork.ensure();
return branch(() => this.#children(this.#anchor)); return branch(() => this.#children(this.#anchor));
}); });

@ -1,4 +1,5 @@
/** @import { Derived, Effect, Source } from '#client' */ /** @import { Derived, Effect, Source } from '#client' */
/** @import { Fork } from './forks.js'; */
import { DEV } from 'esm-env'; import { DEV } from 'esm-env';
import { import {
CLEAN, CLEAN,
@ -123,14 +124,14 @@ export function async_derived(fn, location) {
var restore = capture(); var restore = capture();
var fork = active_fork; var fork = /** @type {Fork} */ (active_fork);
var ran = boundary.ran; var ran = boundary.ran;
if (should_suspend) { if (should_suspend) {
if (!ran) { if (!ran) {
boundary.increment(); boundary.increment();
} else { } else {
fork?.increment(); fork.increment();
} }
} }
@ -147,17 +148,13 @@ export function async_derived(fn, location) {
if (!ran) { if (!ran) {
boundary.decrement(); boundary.decrement();
} else { } else {
fork?.decrement(); fork.decrement();
} }
} }
if (fork !== null) { fork.run(() => {
fork.run(() => {
internal_set(signal, v);
});
} else {
internal_set(signal, v); internal_set(signal, v);
} });
if (DEV && location !== undefined) { if (DEV && location !== undefined) {
recent_async_deriveds.add(signal); recent_async_deriveds.add(signal);

Loading…
Cancel
Save