Members
parsers Array<LoaderParser>
All loader parsers registered
promiseCache Record<string, PromiseAndParser>
Cache loading promises that ae currently active
Methods
Loads one or more assets using the parsers added to the Loader.
Name | Type | Attributes | Description |
---|---|---|---|
assetsToLoadIn |
string | string[] | ResolvedAsset | ResolvedAsset[] |
urls that you want to load, or a single one! |
|
onProgress |
(progress: number) => void |
<optional> |
For multiple asset loading only, an optional function that is called
when progress on asset loading is made. The function is passed a single parameter, |
Returns:
Type | Description |
---|---|
Promise<T | Record<string, T>> |
Example
// Single asset:
const asset = await Loader.load('cool.png');
console.log(asset);
// Multiple assets:
const assets = await Loader.load(['cool.png', 'cooler.png']);
console.log(assets);
function used for testing
Unloads one or more assets. Any unloaded assets will be destroyed, freeing up memory for your app. The parser that created the asset, will be the one that unloads it.
Name | Type | Description |
---|---|---|
assetsToUnloadIn |
string | string[] | ResolvedAsset | ResolvedAsset[] |
urls that you want to unload, or a single one! |
Returns:
Type | Description |
---|---|
Promise<void> |
Example
// Single asset:
const asset = await Loader.load('cool.png');
await Loader.unload('cool.png');
console.log(asset.destroyed); // true