I'm initializing a page using multiple WebSocket queries (I receive the results via the onmessage event and then call the right callback function for each message I receive).
i.e:
query("get_users",callback1);
query("get_weather",callback2);
...
Now I want to display a loader (spinner) and make it disappear only after all the data has been loaded (all callbacks are done). I know that I can make the callbacks update a counter, but I'm looking for a more elegant way to do this, if possible.
I tried using JQuery Promises but couldn't understand how to use it with WebSockets (instead of Ajax calls).
please help.