Is there a way to add promises to a promise.all after it's started?
If not is there a way I can accomplish the same behavior or am I looking at building out a custom solution?
Is there a way to add promises to a promise.all after it's started?
If not is there a way I can accomplish the same behavior or am I looking at building out a custom solution?
Turns out promises don't work how I thought and they're just a fancy callback system. What I've learned since posting this is that when you call a function that returns a promise the code starts executing immediately and doesn't wait until you await it.
I changed my approach here to collecting the media to be uploaded into an array and when the user exits the camera I loop through the array of media and batch them into a Promise.all, seems to work well!
let copy = [...this.media_to_upload]
this.media_to_upload = [];
while(copy.length){
await Promise.all( copy.splice(0, 5).map(media => this.MEDIA_EVENT(media) ))
}