For performance purposes, I want to run a for loop without awaiting the code inside, but there's another function that I want to execute only after everything in the for loop is done. Here's an example:
function waitForThis() {
for (let i = 0; i < 10; i++) {
downloadImage() // I don't want to wait for this
}
}
waitForThis() // I want to wait for all 10 images to be downloaded
runAfter() // Run this after all downloadImage() have completed
If I add await in front of downloadImage()
, I wouldn't be able to download an image until the previous one is finished, so I want to do it synchronously. Any ideas?