Skip to content

Instantly share code, notes, and snippets.

@dannyfritz
Forked from bthesorceror/example.js
Last active January 12, 2018 05:36
Show Gist options
  • Save dannyfritz/03441f0b252df795973509dda75650b5 to your computer and use it in GitHub Desktop.
Save dannyfritz/03441f0b252df795973509dda75650b5 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 = promise.resolve
return promise
}
const files = ["file1", "file2", "file3"]
Promise.all(files.map(loadFile)).then(function () {
// After all files load
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment