Skip to content

withProgress

withProgress<T>(tasks, onProgress): Promise<{ -readonly [K in string | number | symbol]: Awaited<T[K]> }>

Waits for several loads like Promise.all and reports each one that finishes, for a loading bar: const [t, s] = await withProgress([renderer.loadTextures({...}), audio.loadSounds({...})], (done, total) => (Sprite.w[bar] = (200 * done) / total)). Each task counts once, so pass separate loads for a finer bar. Start the game first (game.start()) so the bar draws.

T extends readonly unknown[]

T

(done, total) => void

Promise<{ -readonly [K in string | number | symbol]: Awaited<T[K]> }>