Skip to main content

Class: ImageCache

Defined in: asset-loading/asset-caches/image-cache.ts:6

Class to manage the caching and loading of images.

Implements​

Constructors​

Constructor​

new ImageCache(): ImageCache

Returns​

ImageCache

Properties​

assets​

assets: Map<string, HTMLImageElement>

Defined in: asset-loading/asset-caches/image-cache.ts:7

A map of asset keys to their corresponding assets.

Implementation of​

AssetCache.assets

Methods​

get()​

get(path): HTMLImageElement

Defined in: asset-loading/asset-caches/image-cache.ts:15

Retrieves an image from the cache.

Parameters​

path​

string

The path of the image to retrieve.

Returns​

HTMLImageElement

The cached image element.

Throws​

Will throw an error if the image is not found in the cache.

Implementation of​

AssetCache.get


getOrLoad()​

getOrLoad(path): Promise<HTMLImageElement>

Defined in: asset-loading/asset-caches/image-cache.ts:57

Retrieves an image from the cache if it exists, otherwise loads and caches it.

Parameters​

path​

string

The path of the image to retrieve or load.

Returns​

Promise<HTMLImageElement>

A promise that resolves to the image element.

Implementation of​

AssetCache.getOrLoad


load()​

load(path): Promise<void>

Defined in: asset-loading/asset-caches/image-cache.ts:31

Loads an image from the specified path and caches it.

Parameters​

path​

string

The path of the image to load.

Returns​

Promise<void>

A promise that resolves when the image is loaded and cached.

Throws​

Will throw an error if the image fails to load.

Implementation of​

AssetCache.load