Socket.io-client-swift: how to remove a particular listener?

Created on 26 May 2016  ·  4Comments  ·  Source: socketio/socket.io-client-swift

Most helpful comment

If you only have one of a listener, or you want to remove all listeners for an event, you can use

socket.off("event")

but if you want to be super specific you'll have to save the UUID that's returned from on

let uuid = socket.on("event", someHandler)
socket.off(id: uuid)

All 4 comments

If you only have one of a listener, or you want to remove all listeners for an event, you can use

socket.off("event")

but if you want to be super specific you'll have to save the UUID that's returned from on

let uuid = socket.on("event", someHandler)
socket.off(id: uuid)

thanks nuclearace it helped me......

This answer did not work for me! Instead I did this (and it worked!):
socket.on("event" , someHandler); socket.removeListener("event", someHandler);

Thanks @tomergev
it worked out well for me!

Was this page helpful?
0 / 5 - 0 ratings