Update src/runtime/internal/scheduler.ts

pull/7516/head
Simon H 4 years ago committed by GitHub
parent 86a25363f3
commit 3c08392549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,12 +108,13 @@ function update($$) {
} }
} }
// For example, execute remaining `afterUpdate` before execute `destroy` through this function. /**
// Doing this will prevent to execute `afterUpdate` after execute `destroy`. * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.
*/
export function flush_render_callbacks(fns: Function[]) { export function flush_render_callbacks(fns: Function[]) {
const filtered = []; const filtered = [];
const targets = []; const targets = [];
render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)); render_callbacks.forEach((c) => fns.includes(c) ? filtered.push(c) : targets.push(c));
targets.forEach((c) => c()); targets.forEach((c) => c());
render_callbacks = filtered; render_callbacks = filtered;
} }

Loading…
Cancel
Save