fix/simplify

pull/16394/head
Rich Harris 2 months ago
parent b5028dcb1a
commit eac029c725

@ -59,7 +59,6 @@ let queued_root_effects = [];
let last_scheduled_effect = null; let last_scheduled_effect = null;
let is_flushing = false; let is_flushing = false;
let in_flush_sync = false;
export class Batch { export class Batch {
/** /**
@ -417,7 +416,7 @@ export class Batch {
return (this.#deferred ??= deferred()).promise; return (this.#deferred ??= deferred()).promise;
} }
static ensure() { static ensure(in_flush_sync = false) {
if (current_batch === null) { if (current_batch === null) {
const batch = (current_batch = new Batch()); const batch = (current_batch = new Batch());
batches.add(current_batch); batches.add(current_batch);
@ -446,15 +445,13 @@ export class Batch {
* @returns {T} * @returns {T}
*/ */
export function flushSync(fn) { export function flushSync(fn) {
in_flush_sync = true;
if (async_mode_flag && active_effect !== null) { if (async_mode_flag && active_effect !== null) {
e.flush_sync_in_effect(); e.flush_sync_in_effect();
} }
var result; var result;
const batch = Batch.ensure(); const batch = Batch.ensure(true);
if (fn) { if (fn) {
batch.flush_effects(); batch.flush_effects();
@ -478,8 +475,6 @@ export function flushSync(fn) {
dev_effect_stack = []; dev_effect_stack = [];
} }
in_flush_sync = false;
return /** @type {T} */ (result); return /** @type {T} */ (result);
} }

Loading…
Cancel
Save