Interface LoaderParser<ASSET, META_DATA, CONFIG>

All functions are optional here. The flow:

for every asset,

  1. parser.test(): Test the asset url.
  2. parser.load(): If test passes call the load function with the url
  3. parser.testParse(): Test to see if the asset should be parsed by the plugin
  4. parse.parse(): If test is parsed, then run the parse function on the asset.

some plugins may only be used for parsing, some only for loading and some for both!

Memberof

PIXI

interface LoaderParser<ASSET, META_DATA, CONFIG> {
    config?: CONFIG;
    extension?: ExtensionMetadata;
    load?: (<T>(url, resolvedAsset?, loader?) => Promise<T>);
    name?: string;
    parse?: (<T>(asset, resolvedAsset?, loader?) => Promise<T>);
    test?: ((url, resolvedAsset?, loader?) => boolean);
    testParse?: ((asset, resolvedAsset?, loader?) => Promise<boolean>);
    unload?: ((asset, resolvedAsset?, loader?) => void);
}

Type Parameters

  • ASSET = any
  • META_DATA = any
  • CONFIG = Record<string, any>

Properties

config?: CONFIG

A config to adjust the parser

extension?: ExtensionMetadata
load?: (<T>(url, resolvedAsset?, loader?) => Promise<T>)

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

Type declaration

    • <T>(url, resolvedAsset?, loader?): Promise<T>
    • Type Parameters

      • T

      Parameters

      • url: string

        The URL to load

      • Optional resolvedAsset: ResolvedAsset<META_DATA>

        Any custom additional information relevant to the asset being loaded

      • Optional loader: Loader

        The loader instance

      Returns Promise<T>

name?: string

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

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

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

Type declaration

    • <T>(asset, resolvedAsset?, loader?): Promise<T>
    • Type Parameters

      • T

      Parameters

      • asset: ASSET

        The loaded asset data

      • Optional resolvedAsset: ResolvedAsset<META_DATA>

        Any custom additional information relevant to the asset being loaded

      • Optional loader: Loader

        The loader instance

      Returns Promise<T>

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

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!

Type declaration

    • (url, resolvedAsset?, loader?): boolean
    • Parameters

      • url: string

        The URL to test

      • Optional resolvedAsset: ResolvedAsset<META_DATA>

        Any custom additional information relevant to the asset being loaded

      • Optional loader: Loader

        The loader instance

      Returns boolean

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

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

Type declaration

    • (asset, resolvedAsset?, loader?): Promise<boolean>
    • Parameters

      • asset: ASSET

        The loaded asset data

      • Optional resolvedAsset: ResolvedAsset<META_DATA>

        Any custom additional information relevant to the asset being loaded

      • Optional loader: Loader

        The loader instance

      Returns Promise<boolean>

unload?: ((asset, resolvedAsset?, loader?) => void)

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

Type declaration

    • (asset, resolvedAsset?, loader?): void
    • Parameters

      • asset: ASSET

        The asset to unload/destroy

      • Optional resolvedAsset: ResolvedAsset<META_DATA>

        Any custom additional information relevant to the asset being loaded

      • Optional loader: Loader

        The loader instance

      Returns void

Generated using TypeDoc