Created
January 12, 2018 05:33
-
-
Save bthesorceror/173fdee2e385f2978ff05936e343864f to your computer and use it in GitHub Desktop.
Promises
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
function loadFile(filename) { | |
let script = ... create script with file | |
let promise = new Promise() | |
script.onload = function () { | |
promise.resolve() | |
} | |
return promise | |
} | |
Promise.all([ | |
loadFile('file1'), | |
loadFile('file2'), | |
loadFile('file3'), | |
]).then(function () { | |
// After all files load | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment