angular-socket-io
angular-socket-io copied to clipboard
Preventing duplicate listeners
Hi, GREAT service! Thanks! I have 2 questions:
-
In the docs you write:
Avoid duplicating event handlers when a user navigates back and forth between routes:
I've found this part in the code:scope.$on('$destroy', function () { socket.removeListener(eventName, forwardBroadcast); });
Did you mean this part is taking care of the duplicate issue? So I can create as many listeners as I want without fearing they would somehow remain? -
When I inject the factory, it instantiates it. So now in my controller I have this
mySocket
which is actuallysocketFactory()
. If I injectmySocket
again, in a directive for instance, would it retrieve the same object or create a new instance? And if it is a new instance, would it create a new listener?
Thanks
+1
@YonatanKra do you find any solution?