MCPcopy
hub / github.com/sveltejs/svelte / tick

Function tick

packages/svelte/src/internal/client/runtime.js:494–510  ·  packages/svelte/src/internal/client/runtime.js::tick
()

Source from the content-addressed store, hash-verified

492 * @returns {Promise<void>}
493 */
494export async function tick() {
495 if (async_mode_flag) {
496 return new Promise((f) => {
497 class="cm">// Race them against each other - in almost all cases requestAnimationFrame will fire first,
498 class="cm">// but e.g. in case the window is not focused or a view transition happens, requestAnimationFrame
499 class="cm">// will be delayed and setTimeout helps us resolve fast enough in that case
500 requestAnimationFrame(() => f());
501 setTimeout(() => f());
502 });
503 }
504
505 await Promise.resolve();
506
507 class="cm">// By calling flushSync we guarantee that any pending state changes are applied after one tick.
508 class="cm">// TODO look into whether we can make flushing subsequent updates synchronously in the future.
509 flushSync();
510}
511
512/**
513 * Returns a promise that resolves once any state changes, and asynchronous work resulting from them,

Callers 2

bind_valueFunction · 0.90
animateFunction · 0.50

Calls 2

flushSyncFunction · 0.90
fFunction · 0.85

Tested by

no test coverage detected