On the one hand, I have several factories where each factory controls a websocket.
On the other hand, One of those factories should be started when client is logged, so:
if(user.isLogged()){ $injector.get('NotificationsWebsocket') }
That's the way I initialize my factory dinamically, the problem come up when the user logs out.
I don't know how to delete an instance of angular instances factory or how to destroy the NotificationsWebsocket. I tried to close socket, but when I log in again, the socket doesn't connect because factory is not reinstanciated.