angular-socket-io icon indicating copy to clipboard operation
angular-socket-io copied to clipboard

Preventing duplicate listeners

Open YonatanKra opened this issue 10 years ago • 2 comments

Hi, GREAT service! Thanks! I have 2 questions:

  1. 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?

  2. When I inject the factory, it instantiates it. So now in my controller I have this mySocket which is actually socketFactory(). If I inject mySocket 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

YonatanKra avatar Feb 19 '15 14:02 YonatanKra

+1

burakkilic avatar Oct 31 '15 13:10 burakkilic

@YonatanKra do you find any solution?

paredesivan avatar Aug 26 '16 13:08 paredesivan