[SignalR] Strongly-typed Hub Proxies
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
Edits from @anurse
Let's use this to track strongly-typed hub proxies all-up. We've talked about a few ways of doing it (code-gen, reflection emit, etc.). We have to consider a few things
* Which clients *can* support it?
* Which client environments can support it (for example, AOT environments like Unity wouldn't be able to support reflection emit-based generation)?
* What's the API
* How does this interact with client-side hubs #5278
Original issue follows
---
On the server side, we can create a strongly-typed hub (docs: https://docs.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-3.0#strongly-typed-hubs). However, on the client-side, everything is still loosely typed, which means we lose type safety. Does the TypeScript client have any support for a strongly-typed connection? I imagine it could use generics on the `build` function, eg:
```
const connection = new HubConnectionBuilder()
.withUrl("/hub")
.build();
```
My ideal setup would be automatically generating a TypeScript client based on the C# strongly-typed Hub, but for now I'd be fine just manually creating a TypeScript type that replicates the server-side one.
Contributor guide
Assessment
This issue has not been assessed yet.