|
|
|
|
@ -69,6 +69,14 @@ let last_scheduled_effect = null;
|
|
|
|
|
let is_flushing = false;
|
|
|
|
|
export let is_flushing_sync = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* During traversal, this is an array. Newly created effects are (if not immediately
|
|
|
|
|
* executed) pushed to this array, rather than going through the scheduling
|
|
|
|
|
* rigamarole that would cause another turn of the flush loop.
|
|
|
|
|
* @type {Effect[] | null}
|
|
|
|
|
*/
|
|
|
|
|
export let collected_effects = null;
|
|
|
|
|
|
|
|
|
|
export class Batch {
|
|
|
|
|
/**
|
|
|
|
|
* The current values of any sources that are updated in this batch
|
|
|
|
|
@ -185,7 +193,7 @@ export class Batch {
|
|
|
|
|
this.apply();
|
|
|
|
|
|
|
|
|
|
/** @type {Effect[]} */
|
|
|
|
|
var effects = [];
|
|
|
|
|
var effects = (collected_effects = []);
|
|
|
|
|
|
|
|
|
|
/** @type {Effect[]} */
|
|
|
|
|
var render_effects = [];
|
|
|
|
|
@ -199,6 +207,8 @@ export class Batch {
|
|
|
|
|
// log_inconsistent_branches(root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
collected_effects = null;
|
|
|
|
|
|
|
|
|
|
if (this.#is_deferred()) {
|
|
|
|
|
this.#defer_effects(render_effects);
|
|
|
|
|
this.#defer_effects(effects);
|
|
|
|
|
@ -631,6 +641,7 @@ function flush_effects() {
|
|
|
|
|
|
|
|
|
|
is_flushing = false;
|
|
|
|
|
last_scheduled_effect = null;
|
|
|
|
|
collected_effects = null;
|
|
|
|
|
|
|
|
|
|
if (DEV) {
|
|
|
|
|
for (const source of /** @type {Set<Source>} */ (source_stacks)) {
|
|
|
|
|
@ -836,13 +847,7 @@ export function schedule_effect(signal) {
|
|
|
|
|
// if the effect is being scheduled because a parent (each/await/etc) block
|
|
|
|
|
// updated an internal source, or because a branch is being unskipped,
|
|
|
|
|
// bail out or we'll cause a second flush
|
|
|
|
|
if (
|
|
|
|
|
is_flushing &&
|
|
|
|
|
effect === active_effect &&
|
|
|
|
|
(flags & BLOCK_EFFECT) !== 0 &&
|
|
|
|
|
(flags & HEAD_EFFECT) === 0 &&
|
|
|
|
|
(flags & REACTION_RAN) !== 0
|
|
|
|
|
) {
|
|
|
|
|
if (collected_effects !== null && effect === active_effect) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|