Shaku

Shaku JS

Back To Table of Content

Asset

Asset

A loadable asset base class. All asset types inherit from this.

Kind: global class

new Asset(url)

Create the new asset.

Param Type Description
url String Asset URL / identifier.

asset.ready ⇒ Boolean

Get if this asset is ready, ie loaded or created.

Kind: instance property of Asset
Returns: Boolean - True if asset finished loading / creating. This doesn’t mean its necessarily valid, only that its done loading.

asset.url ⇒ String

Get asset’s URL.

Kind: instance property of Asset
Returns: String - Asset URL.

asset.valid ⇒ Boolean

Get if this asset is loaded and valid.

Kind: instance property of Asset
Returns: Boolean - True if asset is loaded and valid, false otherwise.

asset.onReady(callback)

Register a method to be called when asset is ready. If asset is already in ready state, will invoke immediately.

Kind: instance method of Asset

Param Type Description
callback function Callback to invoke when asset is ready.

asset.waitForReady() ⇒ Promise

Return a promise to resolve when ready.

Kind: instance method of Asset
Returns: Promise - Promise to resolve when ready.

asset.load(params) ⇒ Promise

Load the asset from it’s URL.

Kind: instance method of Asset
Returns: Promise - Promise to resolve when fully loaded.

Param Type Description
params \* Optional additional params.

asset.create(source, params) ⇒ Promise

Create the asset from data source.

Kind: instance method of Asset
Returns: Promise - Promise to resolve when asset is ready.

Param Type Description
source \* Data to create asset from.
params \* Optional additional params.

asset.destroy()

Destroy the asset, freeing any allocated resources in the process.

Kind: instance method of Asset