Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/runtime/internal/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,23 @@ export function add_flush_callback(fn) {
flush_callbacks.push(fn);
}

let flushing = false;
const seen_callbacks = new Set();
export function flush() {
if (flushing) return;
flushing = true;

do {
// first, call beforeUpdate functions
// and update components
while (dirty_components.length) {
const component = dirty_components.shift();
for (let i = 0; i < dirty_components.length; i += 1) {
const component = dirty_components[i];
set_current_component(component);
update(component.$$);
}

dirty_components.length = 0;

while (binding_callbacks.length) binding_callbacks.pop()();

// then, once components are updated, call
Expand All @@ -67,6 +72,7 @@ export function flush() {
}

update_scheduled = false;
flushing = false;
seen_callbacks.clear();
}

Expand Down