Socket.io: removeListener not removing listener

Created on 8 Mar 2014  ·  4Comments  ·  Source: socketio/socket.io

I have this wrapper for socket.io:

on: function (eventName, callback) {
            console.log('socket on hit');
            socket.on(eventName, function () {
                var args = arguments;
                $rootScope.$apply(function () {
                    callback.apply(socket, args);
                });

            });

            //removes duplicate listener
//            console.log('about to remove a listener') ;
            socket.removeListener(eventName, callback);
        }

This leaves me with duplicate listeners over time.

Most helpful comment

We still facing the same issue more than 2 years later. I think remove a single listener should be something basic.

All 4 comments

This is still an issue. When I use removeListener, it doesn't remove the event but using removeAllListeners works.

+1 only removeAllListeners is working properly

We still facing the same issue more than 2 years later. I think remove a single listener should be something basic.

any solution to this yet?

Was this page helpful?
0 / 5 - 0 ratings