Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async generator based streaming API in javascript #60585

Open
1 task done
davidfowl opened this issue Feb 24, 2025 · 1 comment
Open
1 task done

Support async generator based streaming API in javascript #60585

davidfowl opened this issue Feb 24, 2025 · 1 comment
Labels
area-signalr Includes: SignalR clients and servers

Comments

@davidfowl
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

JavaScript supports async generators now and SignalR still only supports the RX based callback model:

https://learn.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-9.0

Describe the solution you'd like

https://learn.microsoft.com/en-us/aspnet/core/signalr/streaming?view=aspnetcore-9.0#javascript-client

An API that looks like this:

var stream = await connection.streamAsync("Counter", 10, 500);

try
{
    for await (const value of stream)
    {
          var li = document.createElement("li");
          li.textContent = item;
          document.getElementById("messagesList").appendChild(li);
    }
}
catch(err)
{
    var li = document.createElement("li");
    li.textContent = err;
    document.getElementById("messagesList").appendChild(li);   
}

var li = document.createElement("li");
li.textContent = "Stream completed";
document.getElementById("messagesList").appendChild(li);

Additional context

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-signalr Includes: SignalR clients and servers label Feb 24, 2025
@davidfowl
Copy link
Member Author

cc @BrennanConroy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

No branches or pull requests

1 participant