Keep track of flushing state

pull/4356/head
Jordan Gensler 6 years ago
parent 45053c26e3
commit 508d523022

@ -31,8 +31,11 @@ export function add_flush_callback(fn) {
flush_callbacks.push(fn); flush_callbacks.push(fn);
} }
let flushing = false;
const seen_callbacks = new Set(); const seen_callbacks = new Set();
export function flush() { export function flush() {
if (flushing) return;
flushing = true;
do { do {
// first, call beforeUpdate functions // first, call beforeUpdate functions
@ -42,7 +45,7 @@ export function flush() {
set_current_component(component); set_current_component(component);
update(component.$$); update(component.$$);
} }
dirty_components.length = 0; dirty_components.length = 0;
while (binding_callbacks.length) binding_callbacks.pop()(); while (binding_callbacks.length) binding_callbacks.pop()();
@ -69,6 +72,7 @@ export function flush() {
} }
update_scheduled = false; update_scheduled = false;
flushing = false;
seen_callbacks.clear(); seen_callbacks.clear();
} }

Loading…
Cancel
Save