Angualr signalR socket returns same value everytime I change route

Viewed 29

I'm using angular signalR socket and reciving data from socket everytime I click on button I'm listening to socket in the ngOnInit() of component The problem is when I change the route the socket returns the same data again .

myComponent.ts

..
ngOnInit(): void {

       console.log("hi")
       this._hubConnection.start().then(() => {

                console.log("connected to socket")

              }).catch(err => console.error(err.toString()));

every time I change the route the console keeps showing connected to socket the ngOnInit() is working only once because "Hi" came from console.log("hi") shows only once so the problem in signalR socket

}

0 Answers
Related