Skip to content

Commit 5518e98

Browse files
committed
WIP
1 parent 6e26478 commit 5518e98

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @import { Effect, Source } from '#client' */
22
import { DIRTY } from '#client/constants';
3-
import { noop } from '../../shared/utils.js';
4-
import { flushSync } from '../runtime.js';
3+
import { schedule_effect, set_signal_status } from '../runtime.js';
54
import { raf } from '../timing.js';
65
import { internal_set, mark_reactions, pending } from './sources.js';
76

@@ -31,6 +30,9 @@ export class Batch {
3130
/** @type {Map<Source, any>} */
3231
#current = new Map();
3332

33+
/** @type {Set<Effect>} */
34+
effects = new Set();
35+
3436
/** @type {Set<Effect>} */
3537
skipped_effects = new Set();
3638

@@ -49,6 +51,13 @@ export class Batch {
4951
source.v = current;
5052
}
5153

54+
for (const e of this.effects) {
55+
if (e.fn) {
56+
set_signal_status(e, DIRTY);
57+
schedule_effect(e);
58+
}
59+
}
60+
5261
for (const batch of batches) {
5362
if (batch === this) continue;
5463

packages/svelte/src/internal/client/runtime.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,18 @@ function flush_queued_root_effects() {
718718
batch.commit();
719719
flush_queued_effects(render_effects);
720720
flush_queued_effects(effects);
721+
} else {
722+
// store the effects on the batch so that they run next time,
723+
// even if they don't get re-dirtied
724+
for (const e of render_effects) {
725+
batch.effects.add(e);
726+
set_signal_status(e, CLEAN);
727+
}
728+
729+
for (const e of effects) {
730+
batch.effects.add(e);
731+
set_signal_status(e, CLEAN);
732+
}
721733
}
722734

723735
revert();

0 commit comments

Comments
 (0)