Skip to content

Signalr typescript client provide stream to AsyncGenerator in additional to IStreamResult<T> #47840

@sdcb

Description

@sdcb

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.

I am trying to use signalr client, but found that it returns AsyncGenerator, which not very easy to use in modern APIs like for await:

class HubConnection {
  stream<T = any>(methodName: string, ...args: any[]): IStreamResult<T>;
}

Describe the solution you'd like

A new api that returns AsyncGenerator:

HubConnection {
  stream<T = any>(methodName: string, ...args: any[]): IStreamResult<T>;
  streamAsync<T = any>(methodName: string, ...args: any[]): AsyncGenerator<T>;
}

so I can using for await to execute this streamAsync result:

for await (const c of hubConnection.streamAsync(this.userInput)) {
  resp.content += c;
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions