progress i think?

async-svelte-map
Rich Harris 6 months ago
parent dac3364087
commit 903eedb861

@ -166,6 +166,9 @@ export class Batch {
#decrement_queued = false; #decrement_queued = false;
/** @type {Set<Batch>} */
#blockers = new Set();
#is_deferred() { #is_deferred() {
return this.is_fork || this.#blocking_pending > 0; return this.is_fork || this.#blocking_pending > 0;
} }
@ -241,7 +244,7 @@ export class Batch {
collected_effects = null; collected_effects = null;
legacy_updates = null; legacy_updates = null;
if (this.#is_deferred()) { if (this.#is_deferred() || this.#blockers.size > 0) {
this.#defer_effects(render_effects); this.#defer_effects(render_effects);
this.#defer_effects(effects); this.#defer_effects(effects);
@ -509,7 +512,10 @@ export class Batch {
this.#pending -= 1; this.#pending -= 1;
if (blocking) this.#blocking_pending -= 1; if (blocking) this.#blocking_pending -= 1;
if (this.#decrement_queued || skip) return; if (this.#decrement_queued || skip) {
return;
}
this.#decrement_queued = true; this.#decrement_queued = true;
queue_micro_task(() => { queue_micro_task(() => {
@ -556,6 +562,8 @@ export class Batch {
} }
apply() { apply() {
this.#blockers.clear();
if (!async_mode_flag || (!this.is_fork && batches.size === 1)) { if (!async_mode_flag || (!this.is_fork && batches.size === 1)) {
batch_values = null; batch_values = null;
return; return;
@ -575,18 +583,19 @@ export class Batch {
continue; continue;
} }
var coincides = false; var intersects = false;
var differs = false;
if (is_earlier) { if (is_earlier) {
for (const source of batch.current.keys()) { for (const source of batch.current.keys()) {
if (this.current.has(source)) { intersects ||= this.current.has(source);
coincides = true; differs ||= !this.current.has(source);
break;
}
} }
} }
if (!coincides) { if (intersects && differs) {
this.#blockers.add(batch);
} else {
for (const [source, previous] of batch.previous) { for (const [source, previous] of batch.previous) {
if (!batch_values.has(source)) { if (!batch_values.has(source)) {
batch_values.set(source, previous); batch_values.set(source, previous);

Loading…
Cancel
Save