LogoPixi’VN
pixi-jsInterfaces

Interface: LoaderParser<ASSET, META_DATA, CONFIG>

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:95

The interface to define a loader parser (all functions are optional).

When you create a parser object, the flow for every asset loaded is:

  1. parser.test() - Each URL to load will be tested here, if the test is passed the assets are loaded using the load function below. Good place to test for things like file extensions!
  2. parser.load() - This is the promise that loads the URL provided resolves with a loaded asset if returned by the parser.
  3. parser.testParse() - This function is used to test if the parse function should be run on the asset If this returns true then parse is called with the asset
  4. parse.parse() - Gets called on the asset it testParse passes. Useful to convert a raw asset into something more useful

Advanced

Extends

Type Parameters

ASSET

ASSET = any

META_DATA

META_DATA = any

CONFIG

CONFIG = Record<string, any>

Properties

config?

> optional config?: CONFIG

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:28

A config to adjust the parser

Inherited from

LoaderParserAdvanced.config


extension?

> optional extension?: ExtensionMetadata

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:26

Should be ExtensionType.LoaderParser

Inherited from

LoaderParserAdvanced.extension


id

> id: string

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:34

The name of the parser (this can be used when specifying parser in a ResolvedAsset)

Inherited from

LoaderParserAdvanced.id


load?

> optional load?: <T>(url, resolvedAsset?, loader?) => Promise<ASSET | T>

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:51

This is the promise that loads the URL provided resolves with a loaded asset if returned by the parser.

Type Parameters

T

T

Parameters

url

string

The URL to load

resolvedAsset?

ResolvedAsset<META_DATA>

Any custom additional information relevant to the asset being loaded

loader?

Loader

The loader instance

Returns

Promise<ASSET | T>

Inherited from

LoaderParserAdvanced.load


~~name?~~

> optional name?: string

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:32

Deprecated

Use id instead.

Inherited from

LoaderParserAdvanced.name


parse?

> optional parse?: <T>(asset, resolvedAsset?, loader?) => Promise<ASSET | T>

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:66

Gets called on the asset it testParse passes. Useful to convert a raw asset into something more useful

Type Parameters

T

T

Parameters

asset

ASSET

The loaded asset data

resolvedAsset?

ResolvedAsset<META_DATA>

Any custom additional information relevant to the asset being loaded

loader?

Loader

The loader instance

Returns

Promise<ASSET | T>

Inherited from

LoaderParserAdvanced.parse


test?

> optional test?: (url, resolvedAsset?, loader?) => boolean

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:43

Each URL to load will be tested here, if the test is passed the assets are loaded using the load function below. Good place to test for things like file extensions!

Parameters

url

string

The URL to test

resolvedAsset?

ResolvedAsset<META_DATA>

Any custom additional information relevant to the asset being loaded

loader?

Loader

The loader instance

Returns

boolean

Inherited from

LoaderParserAdvanced.test


testParse?

> optional testParse?: (asset, resolvedAsset?, loader?) => Promise<boolean>

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:59

This function is used to test if the parse function should be run on the asset If this returns true then parse is called with the asset

Parameters

asset

ASSET

The loaded asset data

resolvedAsset?

ResolvedAsset<META_DATA>

Any custom additional information relevant to the asset being loaded

loader?

Loader

The loader instance

Returns

Promise<boolean>

Inherited from

LoaderParserAdvanced.testParse


unload?

> optional unload?: (asset, resolvedAsset?, loader?) => void | Promise<void>

Defined in: node_modules/pixi.js/lib/assets/loader/parsers/LoaderParser.d.ts:74

If an asset is parsed using this parser, the unload function will be called when the user requests an asset to be unloaded. This is useful for things like sounds or textures that can be unloaded from memory

Parameters

asset

ASSET

The asset to unload/destroy

resolvedAsset?

ResolvedAsset<META_DATA>

Any custom additional information relevant to the asset being loaded

loader?

Loader

The loader instance

Returns

void | Promise<void>

Inherited from

LoaderParserAdvanced.unload