Conversation
… disconnected properply if needed
|
Hi @Hcu. Sorry for the very late response. :( Currently a connection is established once, and only once, when the Makes sense? |
|
Yes, the behavior I had experienced was that if I had a socket open on a controller, and I navigated to a route in my angular app which uses a different controller, then the original controller (the one with the socket connection) would continue to live and hence the socket would still receive updates. Therefor I added a disconnect method so I can call that when I navigate to the new route / controller (one that doesn't need the socket). Cheers |
|
Wouldn't it be simpler to just remove the listeners when the controller's scope is destroyed instead of disconnecting the socket altogether? That's easy to do by using the socket.on('someEvent', function(data) {
...
}).bindTo($scope);My concern about a What do you think? |
|
What if we could have a method 'bindOnlyTo'' similar to 'bindTo' . Difference is whenever scope destroyed it 'll disconnect and whenever this method called for scope , then only it will initiate connection. |
|
For disconnect add , at the end of line 90 and after add these line: disconnect: function(){ |
Hi,
Added a disconnect method because I noticed that in my Angular app when I have a controller that uses a socket, upon navigating to a different route, the socket is still alive and well on the controller (that should have been destroyed?).
Hence I added a disconnect method to the socket that I can call on the destroy event of my controller to disconnect the socket properly.
Test for the disconnect included.
Cheers!