async-changeset
Rich Harris 7 months ago
parent 5235642729
commit 00990ad1f6

@ -30,6 +30,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 { changeset } from '../../reactivity/sources.js';
/** /**
* @typedef {{ * @typedef {{
@ -317,10 +318,9 @@ export class Boundary {
} }
/** /**
* @param {Set<Source>} changeset
* @param {(fork: Fork) => void} fn * @param {(fork: Fork) => void} fn
*/ */
fork(changeset, fn) { fork(fn) {
if (!active_fork || !this.#forks.has(active_fork)) { if (!active_fork || !this.#forks.has(active_fork)) {
active_fork = new Fork(this, changeset); active_fork = new Fork(this, changeset);
this.#forks.add(active_fork); this.#forks.add(active_fork);
@ -328,10 +328,7 @@ export class Boundary {
fn(active_fork); fn(active_fork);
if (!active_fork.suspended) { active_fork.commit();
active_fork.commit();
}
active_fork = null; active_fork = null;
} }
@ -427,8 +424,6 @@ export class Fork {
return; return;
} }
this.suspended = false;
for (const e of this.#render_effects) { for (const e of this.#render_effects) {
try { try {
// if (check_dirtiness(e)) { // if (check_dirtiness(e)) {
@ -458,15 +453,11 @@ export class Fork {
} }
increment() { increment() {
if (this.#pending_count++ === 0) { this.#pending_count += 1;
this.suspended = true;
}
} }
decrement() { decrement() {
if (--this.#pending_count === 0) { this.#pending_count -= 1;
this.suspended = false;
}
} }
discard() { discard() {

@ -832,7 +832,7 @@ function process_effects(effect, fork) {
set_signal_status(current_effect, CLEAN); set_signal_status(current_effect, CLEAN);
} }
} else if ((flags & BOUNDARY_EFFECT) !== 0) { } else if ((flags & BOUNDARY_EFFECT) !== 0) {
/** @type {Boundary} */ (current_effect.b).fork(changeset, (fork) => { /** @type {Boundary} */ (current_effect.b).fork((fork) => {
process_effects(/** @type {Effect} */ (current_effect), fork); process_effects(/** @type {Effect} */ (current_effect), fork);
}); });
} else if ((flags & EFFECT) !== 0) { } else if ((flags & EFFECT) !== 0) {

Loading…
Cancel
Save