-
-
Save arthurvasconcelos/15b44b9080d3160be2bfb6f1651aebfd to your computer and use it in GitHub Desktop.
Preloading images using Ember.JS util
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
| import Ember from 'ember'; | |
| var Promise = Ember.RSVP.Promise; | |
| export default function preloadImages(...urls) { | |
| let promises = urls.map(url => { | |
| return new Promise((resolve, reject) => { | |
| let image = new Image(); | |
| image.onload = resolve; | |
| image.onerror = reject; | |
| image.src = url; | |
| }); | |
| }); | |
| return Promise.all(promises); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment