triniwiz / nativescript-socketio

Socket.IO for nativescript
Apache License 2.0
71 stars 31 forks source link

Unbind socketIo events : Off / removeListener #25

Closed odubuc closed 6 years ago

odubuc commented 8 years ago

Is there any way to unbind an event?

from: socketIO.on(event, callback);

to: socketIO.removeListener(event, callback); (like socketio)

or simply: socketIO.off(event,callback);

triniwiz commented 8 years ago

atm no but i will add it

roblav96 commented 8 years ago

@triniwiz @odubuc this is my temp destroy if its something you're looking for

destroy() {
    if (SocketClass._socket) {
        SocketClass._socket.disconnect()
        if (application.ios) {
            SocketClass._socket.instance.removeAllHandlers()
        } else if (application.android) {
            SocketClass._socket.instance.close()
        }
        SocketClass._socket = null
    }
}

lulz

triniwiz commented 8 years ago

@roblav96 there is a .off() just need to wire it up :smiley: thanks anyhow

FranciZ commented 5 years ago

@triniwiz Is it possible to off a specific function like socketIO.off(event,callbackRef);?