createAssets
createAssets<
T>(assetsMap):Assets<T>
Defined in: asset.ts:98
Creates a set of typed asset controllers, one per key in the map.
Each controller exposes show() and hide() methods. It is also
directly awaitable — await assets.logo is shorthand for
await assets.logo.show().
Image assets require a duration (in ms). Calling show() will
automatically record the assetEnd after that many milliseconds. Calling
hide() before the timer fires cancels the auto-hide.
Video assets do not require a duration — the video’s natural length
determines how long it plays. Call hide() explicitly to stop it.
Type Parameters
Section titled “Type Parameters”T extends Record<string, AssetConfig>
Parameters
Section titled “Parameters”assetsMap
Section titled “assetsMap”{ [K in string | number | symbol]: AssetConfigFor<T[K][“path”]> }
Returns
Section titled “Returns”Assets<T>
Example
Section titled “Example”const assets = createAssets({ logo: { path: './logo.png', audio: 0, fullScreen: false, duration: 3000 }, intro: { path: './intro.mp4', audio: 1.0, fullScreen: true },})
await assets.logo // shows logo for 3 s, then auto-hidesawait page.goto('/dashboard')assets.intro.show() // start video overlay (non-blocking for caller)await assets.intro.hide() // hide video overlay manually