|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|