Restore truedm commit: chore: avoid microtasks when flushing sync

# Conflicts:
#	packages/svelte/src/internal/client/runtime.js
pull/16077/head
Dominic Gannaway 5 months ago committed by raythurnvoid
parent c9346ab391
commit 28cef32e69

@ -47,6 +47,7 @@ const handled_errors = new WeakSet();
let is_throwing_error = false;
let is_flushing = false;
let is_flushing_sync = false;
/** @type {Effect | null} */
let last_scheduled_effect = null;
@ -734,8 +735,10 @@ function flush_queued_effects(effects) {
export function schedule_effect(signal) {
if (!is_flushing) {
is_flushing = true;
if (!is_flushing_sync) {
queueMicrotask(flush_queued_root_effects);
}
}
var effect = (last_scheduled_effect = signal);
@ -818,7 +821,11 @@ function process_effects(root) {
* @returns {T}
*/
export function flushSync(fn) {
var previously_flushing_sync = is_flushing_sync;
try {
var result;
is_flushing_sync = true;
if (fn) {
is_flushing = true;
@ -836,6 +843,9 @@ export function flushSync(fn) {
is_flushing = true;
flush_queued_root_effects();
}
} finally {
is_flushing_sync = previously_flushing_sync;
}
}
/**

Loading…
Cancel
Save