An interface to identify an asset and access its individual components. One can imagine it as a folder containing multiple files associated with that asset.

interface IAssetWrapper {
    getComponent(key: string): Promise<Blob>;
    getComponentLocation(key: string): Promise<null | string>;
    getKeys(): Promise<string[]>;
    getType(): Promise<AssetTypeWrapper>;
    preloadComponent(key: string): Promise<void>;
    preloadComponents(): Promise<void>;
}

Methods

  • Get a component of this asset associated with the specified key. Returns a blob incase the component is available, otherwise it will throw an error. This is the entrypoint from which components are requested for local purposes. (aka. when no compute server is involved.)

    Parameters

    • key: string

      The key that the component is associated with.

    Returns Promise<Blob>

    A promise that resolves to the components blob.

  • Get the location of a component of this asset associated with the specified key. Will return null incase an location could not be resolved. This could sometimes be the case when a component is only available locally but has no public location.

    Parameters

    • key: string

      The key that the component is associated with.

    Returns Promise<null | string>

    The location of the component or null. Does not mean that the component behind the url is available.

  • Initiates a pre-loading of all components. Use this with caution as it will load all available assets. Sometimes we don't need to access all assets though. This would trigger unnecessary network transfers and consume additional memory!

    Returns Promise<void>