fetchImage
suspend fun fetchImage(options: IonResource.FetchImageOptions? = definedExternally): CanvasImageSource?(source)
Asynchronously loads the given image resource. Returns a promise that will resolve to an ImageBitmap if preferImageBitmap
is true and the browser supports createImageBitmap
or otherwise an Image once loaded, or reject if the image failed to load.
// load a single image asynchronously
resource.fetchImage().then(function(image) {
// use the loaded image
}).catch(function(error) {
// an error occurred
});
// load several images in parallel
Promise.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) {
// images is an array containing all the loaded images
});
Content copied to clipboard
Return
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.