Created
May 5, 2017 17:30
-
-
Save jhurliman/96adc4482db51387954d68edf36e2477 to your computer and use it in GitHub Desktop.
Wrapper for Promise.all() that adds a progress callback
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
function allWithProgress(promises, callback) { | |
let completed = 0 | |
callback(0, promises.length) | |
promises.forEach(p => { | |
p.then(() => callback(++completed, promises.length)) | |
}) | |
return Promise.all(promises) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment