I’m using socket.io with express 3 to build an app.
I would like to set loader animations to display when on a incoming message, and hide it when the message been recieved.
Much like jQuerys .ajaxStart and .ajaxComplete where i can do something like $('#loader').show(); etc
Are there any events i can catch in socket.io to achieve this?
You can achieve this using the following idea:
about_to_startevent;about_to_startenable the loader and emitdownload_readyevent;download_readyevent send the data, i.e. emitdownloadevent;downloadevent do something with data and disable the loader;That’s how I would do that.
By the way: are we talking about simple messaging system? I don’t think there is a need to do that in that scenario. Downloading won’t take more then few seconds and if it will, then you need to optimize app or add some horse power (i.e. if the traffic is too big, add some machines). Skip steps 1,2 and half of 3. On step 4 you just notify the client: “Hey, you have a new message!”.