I am iterating over an array of assets, I need to load each of these assets to gpu (using third party library for this). Loader provided by such third party library has a callback function that is executed when asset is loaded i.e. right now I have something like this
assetsArr.forEach(asset => {
myLoader.upload(asset, () => {
// Go to next loop / iteration here
})
});
Since this callback is not executed right away I am currently in a situation where my loop finishes before my assets are actually loaded leading to some issues in my app.
Is there a way to loop over assetsArr
, but only go to next iteration / loop once that callback is executed?