dotnet / dotnet/AspNetCore.Docs
SignalR with TypeScript code examples do not match other articles
- Dominant language
- C#
- Stars
- 13.1k
- Forks
- 24.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 97
Description
The method used in the TypeScript example for ChatHub.cs is:
```csharp
public async Task NewMessage(long username, string message)
{
await Clients.All.SendAsync("messageReceived", username, message);
}
```
Both the JavaScript and Blazor examples use:
```csharp
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
```
The differences being:
- `NewMessage` -> `SendMessage`
- `long username` -> `string user`
- `"messageReceived"` -> `"ReceiveMessage"`
This is also present in the `.ts`/`.js.`|`.razor` examples where they call the methods, and anywhere in the article that references to it of course.
Biggest difference (besides the name changes) is that the TypeScript example doesn't have a username input field, it just uses the `Date().getTime()` value
A smaller but similiar difference is the endpoint defined:
TypeScript example
```csharp
endpoints.MapHub("/hub");
```
versus the JavaScript and Blazor example:
```csharp
endpoints.MapHub("/chathub");
```
This tripped me up personally when I was reading the [Strongly Typed Hubs](https://docs.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-3.1#strongly-typed-hubs) article that uses the JavaScript and Blazor example syntax
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 47557f89-3a14-1139-0074-38d931b35faf
* Version Independent ID: 1cee43b4-b672-e480-3e26-72e08a6c2d77
* Content: [Use ASP.NET Core SignalR with TypeScript and Webpack](https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr-typescript-webpack?view=aspnetcore-3.1&tabs=visual-studio&source=docs)
* Content Source: [aspnetcore/tutorials/signalr-typescript-webpack.md](https://github.com/dotnet/AspNetCore.Docs/blob/master/aspnetcore/tutorials/signalr-typescript-webpack.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-tutorials**
* GitHub Login: @ssougnez
* Microsoft Alias: **bradyg**
Contributor guide
Assessment
This issue has not been assessed yet.