I was trying to remove all event listeners from a socket, to a specific event, and found this accepted answer on StackOveflow.
I followed the answer, and tried the following: socket.off('listenerName') to remove all listeners from the listenerName event, but this code gives me an error:
(node:27706) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type undefined
I am using the latest version (2.3.0) of socket.io. So it looks like, that the socket.off() method needs at least 2 parameters to work, and I have to explicitly tell it which function I want to remove. I tried searching socket.io's documentation to find the definition of this function, but all I found is that the socket inherits every method from the Emiter, including the off() method as well.
Does anyone know if there is a function in socket.io, with which I can remove all listeners from a specific event, without explicitly providing it a reference to the originally added function?