AssetSystem
Extends:
Assets database and loader.
Example:
const system = new AssetSystem('assets/', { cache: 'no-store' }, AssetSystem.fetchArrayView);
Static Method Summary
Static Public Methods | ||
public static |
Default browser fetch mechanism. |
|
public static |
fetchArrayView(view: ArrayBufferView, path: string, options: *, fallbackEngine: Function): Promise Custom fetch mechanism that loads data from array view. |
|
public static |
makeFetchEngineWeb(address: string, fallbackEngine: Function): Function Web fetch mechanism generator that loads data from specified address. |
Constructor Summary
Public Constructor | ||
public |
Constructor. |
Member Summary
Public Members | ||
public get |
|
|
public get |
|
|
public set |
|
|
public get |
fetchOptions: * |
|
public get |
|
Method Summary
Public Methods | ||
public |
dispose() Destructor (dispose internal resources and clear assets database). |
|
public |
Get asset by it's full path. |
|
public |
Load asset from given path. |
|
public |
Load list of assets possibly all at the same time (asynchronously). |
|
public |
async loadAllWithFetchEngine(paths: Array<string>, fetchEngine: Function): Promise Load list of assets possibly all at the same time (asynchronously) with specified fetch engine. |
|
public |
async loadSequence(paths: Array<string>): Promise Load list of assets in sequence (one by one). |
|
public |
async loadSequenceWithFetchEngine(paths: Array<string>, fetchEngine: Function): Promise Load list of assets in sequence (one by one) with specified fetch engine. |
|
public |
async loadWithFetchEngine(path: string, fetchEngine: Function): Promise Load asset from given path with specified fetch engine. |
|
public |
|
|
public |
registerProtocol(protocol: string, assetConstructor: Function) Register assets loader under given protocol. |
|
public |
Unload asset by path and remove from database. |
|
public |
Unload all assets from paths list. |
|
public |
unregisterProtocol(protocol: string) Unregister given assets loader protocol. |
Inherited Summary
From class System | ||
public static get |
|
|
public static get |
systems: * |
|
public static |
dispose() Dispose and remove all registered systems. |
|
public static |
Returns system instance of given type name. |
|
public static |
Register new system instance under given name. |
|
public static |
unregister(typename: string): System Unregister given system. |
|
public |
dispose() Destructor (disposes all internal resources). |
|
public |
Event called after system gets registered. |
|
public |
Event called before system gets unregistered. |
Static Public Methods
public static fetch(args: *): Promise source
Default browser fetch mechanism.
Params:
Name | Type | Attribute | Description |
args | * | Fetch engine parameters. |
public static fetchArrayView(view: ArrayBufferView, path: string, options: *, fallbackEngine: Function): Promise source
Custom fetch mechanism that loads data from array view.
Public Constructors
Public Members
public get fetchOptions: * source
Public Methods
public dispose() source
Destructor (dispose internal resources and clear assets database).
Override:
System#disposeExample:
system.dispose();
system = null;
public get(path: string): Asset | null source
Get asset by it's full path.
Override:
System#getParams:
Name | Type | Attribute | Description |
path | string | Asset path (with protocol). |
Example:
const config = system.get('json://config.json');
public load(path: string): Promise source
Load asset from given path.
Params:
Name | Type | Attribute | Description |
path | string | Asset path (with protocol). |
Example:
system.load('json://config.json').then(asset => console.log(asset.data));
public async loadAll(paths: Array<string>): Promise source
Load list of assets possibly all at the same time (asynchronously).
Example:
const list = [ 'json://config.json', 'text://hello.txt' ];
system.loadAll(list).then(assets => console.log(assets.map(a => a.data)));
public async loadAllWithFetchEngine(paths: Array<string>, fetchEngine: Function): Promise source
Load list of assets possibly all at the same time (asynchronously) with specified fetch engine.
Example:
const list = [ 'json://config.json', 'text://hello.txt' ];
system.loadAllWithFetchEngine(list, AssetSystem.fetch).then(assets => console.log(assets.map(a => a.data)));
public async loadSequence(paths: Array<string>): Promise source
Load list of assets in sequence (one by one).
Example:
const list = [ 'json://config.json', 'text://hello.txt' ];
system.loadSequence(list).then(assets => console.log(assets.map(a => a.data)));
public async loadSequenceWithFetchEngine(paths: Array<string>, fetchEngine: Function): Promise source
Load list of assets in sequence (one by one) with specified fetch engine.
Example:
const list = [ 'json://config.json', 'text://hello.txt' ];
system.loadSequenceWithFetchEngine(list, AssetSystem.fetch).then(assets => console.log(assets.map(a => a.data)));
public async loadWithFetchEngine(path: string, fetchEngine: Function): Promise source
Load asset from given path with specified fetch engine.
Example:
system.loadWithFetchEngine('json://config.json', AssetSystem.fetch).then(asset => console.log(asset.data));
public onUnregister() source
Event called before system gets unregistered.
Override:
System#onUnregisterpublic registerProtocol(protocol: string, assetConstructor: Function) source
Register assets loader under given protocol.
Example:
system.registerProtocol('json', JSONAsset.factory);
public unload(path: string) source
Unload asset by path and remove from database.
Params:
Name | Type | Attribute | Description |
path | string | Asset path (with protocol). |
Example:
system.unload('json://config.json');