()
| 492 | * @returns {Promise<void>} |
| 493 | */ |
| 494 | export 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, |
no test coverage detected