getAsync

inline fun <T> getAsync(path: String): Deferred<T>

Returns the reference to the asset wrapped with Deferred. Use Deferred.await to obtain the instance.

T is the type of the asset. Must match the type requested during loading. path must match the asset path passed during loading.

Note that while the result is a CompletableDeferred, it should never be completed manually. Instead, rely on the AssetStorage to load the asset.

Using Deferred.await might throw the following exceptions:

Otherwise, using Deferred.await will suspend the coroutine until the asset is loaded and return its instance.

See also get and getOrNull for synchronous alternatives.


fun <T> getAsync(descriptor: AssetDescriptor<T>): Deferred<T>

Returns the reference to the asset wrapped with Deferred. Use Deferred.await to obtain the instance. Throws AssetStorageException if the asset was unloaded or never scheduled to begin with.

T is the type of the asset. Must match the type requested during loading. descriptor contains the asset data. See getAssetDescriptor.

Note that while the result is a CompletableDeferred, it should never be completed manually. Instead, rely on the AssetStorage to load the asset.

Using Deferred.await might throw the following exceptions:

Otherwise, using Deferred.await will suspend the coroutine until the asset is loaded and return its instance.

See also get and getOrNull for synchronous alternatives.


fun <T> getAsync(identifier: Identifier<T>): Deferred<T>

Returns the reference to the asset wrapped with Deferred. Use Deferred.await to obtain the instance.

T is the type of the asset. Must match the type requested during loading. identifier uniquely identifies a file by its path and type. See Identifier.

Note that while the result is a CompletableDeferred, it should never be completed manually. Instead, rely on the AssetStorage to load the asset.

Using Deferred.await might throw the following exceptions:

Otherwise, using Deferred.await will suspend the coroutine until the asset is loaded and return its instance.

See also get and getOrNull for synchronous alternatives.