Skip to content

Instantly share code, notes, and snippets.

@bthesorceror
Created January 12, 2018 05:33
Show Gist options
  • Save bthesorceror/173fdee2e385f2978ff05936e343864f to your computer and use it in GitHub Desktop.
Save bthesorceror/173fdee2e385f2978ff05936e343864f to your computer and use it in GitHub Desktop.
Promises
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