This script is designed to continuously attempt loading an image until it is successful:
function loadImage (url = '', callback = () => {}) {
utils.loadImage(url, () => {
callback()
}, () => {
loadImage(url, callback)
})
}
In order to make it return a Promise, the following adjustment was made:
function loadImage (url = '', callback = () => {}) {
return new Promise((resolve, reject) => {
utils.loadImage(url, () => {
// where should we utilize resolve and reject?
callback()
}, () => {
loadImage(url, callback)
})
})
}
The challenge now is determining the correct placement for resolve and reject...