@ -25,7 +25,7 @@ import {
update _effect
} from '../runtime.js' ;
import * as e from '../errors.js' ;
import { flush _tasks } from '../dom/task.js' ;
import { flush _tasks , has _pending _tasks , queue _micro _task } from '../dom/task.js' ;
import { DEV } from 'esm-env' ;
import { invoke _error _boundary } from '../error-handling.js' ;
import { old _values } from './sources.js' ;
@ -56,19 +56,6 @@ export let batch_deriveds = null;
/** @type {Set<() => void>} */
export let effect _pending _updates = new Set ( ) ;
/** @type {Array<() => void>} */
let tasks = [ ] ;
function dequeue ( ) {
const task = /** @type {() => void} */ ( tasks . shift ( ) ) ;
if ( tasks . length > 0 ) {
queueMicrotask ( dequeue ) ;
}
task ( ) ;
}
/** @type {Effect[]} */
let queued _root _effects = [ ] ;
@ -76,7 +63,7 @@ let queued_root_effects = [];
let last _scheduled _effect = null ;
let is _flushing = false ;
let is _flushing _sync = false ;
export let is _flushing _sync = false ;
export class Batch {
/ * *
@ -470,11 +457,7 @@ export class Batch {
/** @param {() => void} task */
static enqueue ( task ) {
if ( tasks . length === 0 ) {
queueMicrotask ( dequeue ) ;
}
tasks . unshift ( task ) ;
queue _micro _task ( task ) ;
}
}
@ -505,7 +488,7 @@ export function flushSync(fn) {
while ( true ) {
flush _tasks ( ) ;
if ( queued _root _effects . length === 0 ) {
if ( queued _root _effects . length === 0 && ! has _pending _tasks ( ) ) {
current _batch ? . flush ( ) ;
// we need to check again, in case we just updated an `$effect.pending()`