Created
June 10, 2017 00:05
-
-
Save zurie/8fbed54de1dd180674791f2927daaa52 to your computer and use it in GitHub Desktop.
This file contains 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
export function imgResolver(resourceProvider: ResourceProvider) { | |
const preloadImgs: string[] = ['/assets/bg_color.jpg', '/assets/bg_bw.jpg']; | |
return new Promise(function (resolve) { | |
const preloadImage = (img: HTMLImageElement) => console.log(img.src + ' loaded!'); | |
const preloadError = (err: Error) => console.log('Preload Error!' + err); | |
const preloadComplete = () => setTimeout(resolve, 0); | |
return resourceProvider.preloadImages(preloadImgs) | |
.subscribe((img: HTMLImageElement) => preloadImage(img), (err: Error) => preloadError(err), () => preloadComplete()); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment