Brought back a guard to prevent calling flush() while flush is running

pull/7722/head
YIFAN WU 4 years ago
parent 52f5005cfd
commit 57fb06ee02
No known key found for this signature in database
GPG Key ID: 0E94BC0683AFCE47

@ -51,7 +51,10 @@ export function add_flush_callback(fn) {
// function, guarantees this behavior. // function, guarantees this behavior.
const seen_callbacks = new Set(); const seen_callbacks = new Set();
let flushidx = 0; // Do *not* move this inside the flush() function let flushidx = 0; // Do *not* move this inside the flush() function
let flushing = false;
export function flush() { export function flush() {
if (flushing) return;
flushing = true;
const saved_component = current_component; const saved_component = current_component;
do { do {
@ -91,6 +94,7 @@ export function flush() {
flush_callbacks.pop()(); flush_callbacks.pop()();
} }
flushing = false;
update_scheduled = false; update_scheduled = false;
seen_callbacks.clear(); seen_callbacks.clear();
set_current_component(saved_component); set_current_component(saved_component);

Loading…
Cancel
Save