DVLP / signalr-no-jquery

120 stars 78 forks source link

how to stop connection go to another page #36

Closed water-melon91 closed 5 years ago

water-melon91 commented 6 years ago

i want to stop another page go i add self.mainconnection = hubConnection('http://'); self.hubProxy = self.mainconnection.createHubProxy('test');

ionViewWillLeave (){ self.mainconnection.stop(); self.hubProxy.connection.stop(); } but this not working how to try another way??

Akihito759 commented 6 years ago

Hey, I have got the same problem :D. You need to unsubscribe events in hubproxy: for example: if you have got

hubProxy.on("test", test)

then you need to remove it manually when you want to change page

hubProxy.off("test",test)

I normal signalR library there is enough to only do: hubProxy = null

they should fix it

pewuel commented 5 years ago

For me works: hubProxy.connection.stop()

Full code:

const connection = hubConnection(yourHost);
const hubProxy = connection.createHubProxy(yourHubName);

hubProxy.connection.stop();

However I'm using TypeScript and I don't know why this method isn't typed.