dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.31k stars 9.97k forks source link

"stateChanged" missing from Typescript SignalR lifetime events? #17900

Open cyraid opened 4 years ago

cyraid commented 4 years ago

Describe the bug

onreconnecting, onreconnected, onclose, and the event from start() are the only ones supported currently in the Typescript client, is this correct?

To Reproduce

Attempt to use stateChanged ..

Further technical details

SignalR for Typescript version 3.1.0.

davidfowl commented 4 years ago

There is no state change event. You might be confusing this with the previous version of SignalR (https://github.com/SignalR/SignalR)

cyraid commented 4 years ago

Actually I was getting it from your docs. The docs state it's for the Javascript client, so I thought it'd be similar?

Are there any Typescript reference / docs / guides / examples? Am I using the wrong SignalR for typescript? In my package.json I have: @microsoft/signalr with version 3.1.0.

analogrelay commented 4 years ago

Actually I was getting it from your docs. The docs state it's for the Javascript client, so I thought it'd be similar?

Those are the docs for the previous version of SignalR. Note the banner at the top of the page:

ASP.NET SignalR docs with a banner indicating that the docs are for a previous version of SignalR

Are you using ASP.NET Core? If so, the docs can be found here: https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-3.1

cyraid commented 4 years ago

Oh, apologies for not reading that. I did a search from Google and plopped on that page and must've scrolled to the events part. Is there a way to get events other than onreconnecting, onclose (specifically for the state field in the HubConnection)?

analogrelay commented 4 years ago

Is there a way to get events other than onreconnecting, onclose (specifically for the state field in the HubConnection)

What other events are you looking for? The only other lifecycle event I can think of here is when the connection is started, but you can know when that happens because the Promise returned by .start() will be completed.

(Moving this to the Discussions milestone as this is more of a question on how to follow lifecycle events. If actionable work comes out the discussion we can file issues for that!)

cyraid commented 4 years ago

Was kinda hoping for all states of:

    /** The hub connection is disconnected. */
    Disconnected = "Disconnected",
    /** The hub connection is connecting. */
    Connecting = "Connecting",
    /** The hub connection is connected. */
    Connected = "Connected",
    /** The hub connection is disconnecting. */
    Disconnecting = "Disconnecting",
    /** The hub connection is reconnecting. */
    Reconnecting = "Reconnecting"

It would also be nice if it were all in an event listener / subscriber type event state change like the 'stateChanged' instead of having to change the onreconnecting, onreconnect, onclose all separately.. Just a nit-pick I suppose. I've made my own subscriber interface using rxjs, and just set the events, and on each event trigger the state change event.

ghost commented 4 years ago

Was kinda hoping for all states of:

    /** The hub connection is disconnected. */
    Disconnected = "Disconnected",
    /** The hub connection is connecting. */
    Connecting = "Connecting",
    /** The hub connection is connected. */
    Connected = "Connected",
    /** The hub connection is disconnecting. */
    Disconnecting = "Disconnecting",
    /** The hub connection is reconnecting. */
    Reconnecting = "Reconnecting"

It would also be nice if it were all in an event listener / subscriber type event state change like the 'stateChanged' instead of having to change the onreconnecting, onreconnect, onclose all separately.. Just a nit-pick I suppose. I've made my own subscriber interface using rxjs, and just set the events, and on each event trigger the state change event.

Came here looking for the exact same thing. StompJS has a stateChanged RxJS Observable that is very nice to work with. Would love to see that added to the signalR library

ghost commented 4 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

davidfowl commented 3 years ago

None of the clients currently support state changed events.