HNeukermans / ng2-signalr

angular2 - asp.net signalr library
MIT License
173 stars 80 forks source link

Know if connection status is connected at first #124

Open facundocoto opened 6 years ago

facundocoto commented 6 years ago

Hi, how know was successfull? Seems like the statusconnections only returns when the connections failure or is reconnecting. But I want to know if cnnection status is 'connected' at first time to try connections.

Thanks

alberthoekstra commented 5 years ago

I think you subscribe ‘to late’ to the status changes.

If you inject the signalrR service into your component or whatsoever you probably use something like this.signalr.connect(); and then subscribe to the status changes.

Then you could miss the connecting and connected state change.

You should do this.signalr.createConnection();, Save the result, subscribe to the state changes, start the connection you received from the createConnection method.

Can’t create code blocks because I’m on phone. Sorry.