Simple script to promisify the API of any javascript Object - It's an experiment don't use it in production!!!!
// simply...
window.promise.onload.then(() => console.log('loaded!'))
// or...
var img2 = new Image()
img2.promise.onload.then(() => console.log('Image loaded!'))
img2.crossOrigin = 'anonymous'
img2.src = 'https://placekitten.com/200/300'
var img = new Image()
img.promise.onerror.then(() => console.log('oh please! I can\'t load this!'))
img.src = 'trump.jpg'
Promise.all([
img.promise.onerror,
img2.promise.onload
]).then(() => {
console.log('Rock and roll!')
})
This code was optimized and included in https://github.com/GianlucaGuarini/allora