OK, I've been looking around to solve this problem, but since JavaScript is single-threaded I'm not sure if it's even possible. Do you guys know if there's an alternative?
Here's what I am trying to accomplish:
I'm making ten asynchronous requests to get data from a server. I want to continue execution of my logic once all ten responses are received, or after 4000 ms have elapsed.
If I was using java I can simply fire ten different threads and have my main thread sleep. Once all ten responses are received or the 4000 ms elapsed, then I can interrupt the thread and continue execution. I just have not idea how to do this in JavaScript.
Any ideas?