Last active
April 1, 2019 15:06
-
-
Save gladchinda/7d7afc1b412146190905ac52208db177 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loadPhoto = photo_url => | |
new Promise(resolve => { | |
const img = new Image(); | |
img.addEventListener('load', () => { | |
resolve(img); | |
}, false); | |
img.addEventListener('error', () => { | |
const rejection = Promise.reject(new Error('Image could not be loaded.')); | |
resolve(rejection); | |
}, false); | |
img.src = photo_url; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment