LoadState

View source

Describes the numeric load lifecycle recorded in asset metadata by an AssetServer.

AssetServer#load starts each new request in LoadState.Loading. The server records LoadState.Loaded when the asset is imported and stored successfully, or LoadState.Failed when loading or importing fails.

Examples

import { AssetServer, Assets, LoadState } from '@wimaengine/asset'

class Texture {}
const server = new AssetServer()
server.registerAsset(new Assets(Texture))
const handle = server.load(Texture, '/textures/player.png')
const info = handle && server.getAssetInfo(handle)

const isPending = info?.loadstate === LoadState.Loading

Variants


Loading

View source

The asset load is queued or still being processed.

Failed

View source

The asset could not be loaded or imported.

Loaded

View source

The asset was imported and stored successfully.