I am looking for a clean JS solution. Do not add to libs, please.
I have a function that throws an XMLHttpRequest indicating standard async operations.
If I call this function, say 5 times, one by one, I set up 5 callbacks for my code. Since JS is the only thread, JS needs to figure out how to cut and cubes the available CPU cycles so that all 5 of my callbacks are completed until completion. It does not say what happens when no callback can rely on anything that other callbacks work on.
If I need to wait until all 5 of my callbacks complete their execution, how can I detect this nonexistent "event"?
I'm not looking for a solution that is based on a combination of things. I am wondering if it is possible to create a real event infrastructure that can be fired to create an event that can be listened to.
source share