You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When emitting multiple events of a similar functionality from the server, One has to apply a 'socket.on' listener to each one of them. Rather than what will be feasible is to have an onMany method which will take in an array of all the expected events and then fire the callback if any of the event is being emitted from the server.
The text was updated successfully, but these errors were encountered:
zoosphar
changed the title
Sponsored issue: Add an onMany method to attach a callback to multiple socket events.
Add an onMany method to attach a callback to multiple socket events.
Nov 21, 2023
I identified some potential issues with the solution you proposed
If there are duplicate values in the array, this can lead to a socket listening to the same event multiple times.
Another potential concern is that if the handler function is stateful (e.g., contains closure variables or relies on an external state), it might behave unexpectedly due to being reused for multiple event listeners.
When emitting multiple events of a similar functionality from the server, One has to apply a 'socket.on' listener to each one of them. Rather than what will be feasible is to have an onMany method which will take in an array of all the expected events and then fire the callback if any of the event is being emitted from the server.
The text was updated successfully, but these errors were encountered: