API/core/AssetPromise/

AssetPromise

Asset Loading Promise.

Hierarchy: Promise

constructor 

new AssetPromise(executor: )

Create an asset loading Promise.

Parameters

  • executor

    A callback used to initialize the promise. This callback is passed two arguments: a resolve callback used to resolve the promise with a value or the result of another promise, and a reject callback used to reject the promise with a provided reason or error. and a setProgress callback used to set promise progress with a percent.

[Symbol.toStringTag] ReadOnly

[Symbol.toStringTag]: string

[Symbol.species] ReadOnly

[Symbol.species]: PromiseConstructor

progress 

get progress(): number

Loading progress.

status 

get status(): AssetPromiseStatus

Current promise state.

cancel 

cancel(): AssetPromise

Cancel promise request.

Returns

Asset promise

catch 

catch<T extends >(onrejected: T): Promise

Attaches a callback for only the rejection of the Promise.

Parameters

  • optionalonrejected

    The callback to execute when the Promise is rejected.

Returns

A Promise for the completion of the callback.

finally 

finally(onfinally: T): Promise

Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

Parameters

  • optionalonfinally

    The callback to execute when the Promise is settled (fulfilled or rejected).

Returns

A Promise for the completion of the callback.

onProgress 

onProgress(callback: T): AssetPromise

Progress callback.

Parameters

  • callback

    Progress callback

Returns

Asset Promise

then 

then<T extends >(onfulfilled: T, onrejected: T): Promise

Attaches callbacks for the resolution and/or rejection of the Promise.

Parameters

  • optionalonfulfilled

    The callback to execute when the Promise is resolved.

  • optionalonrejected

    The callback to execute when the Promise is rejected.

Returns

A Promise for the completion of which ever callback is executed.

all 

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

all<T extends >(values: ): AssetPromise

Parameters

  • values

allSettled 

allSettled<T extends >(values: T): Promise

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Parameters

  • values

    An array of Promises.

Returns

A new Promise.
allSettled<T extends >(values: Iterable): Promise

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Parameters

  • values

    An array of Promises.

Returns

A new Promise.

any 

any<T extends >(values: ): Promise

The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.

Parameters

  • values

    An array or iterable of Promises.

Returns

A new Promise.

race 

race<T extends >(values: Iterable): Promise

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Parameters

  • values

    An iterable of Promises.

Returns

A new Promise.
race<T extends >(values: Iterable): Promise

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Parameters

  • values

    An iterable of Promises.

Returns

A new Promise.
race<T extends >(values: ): Promise

Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

Parameters

  • values

    An array of Promises.

Returns

A new Promise.

reject 

reject<T extends >(reason: any): Promise

Creates a new rejected promise for the provided reason.

Parameters

  • optionalreason

    The reason the promise was rejected.

Returns

A new rejected Promise.

resolve 

resolve<T extends >(value: ): Promise

Creates a new resolved promise for the provided value.

Parameters

  • value

    A promise.

Returns

A promise whose internal state matches the provided promise.
resolve(): Promise

Creates a new resolved promise .

Returns

A resolved promise.