Skip to content

Commit

Permalink
fix example for injected HubConnectionBuilder (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiralSnyder authored and galvesribeiro committed May 20, 2019
1 parent 5f928ea commit 9e9923a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,19 @@ This package implements all public features of SignalR Typescript client.

The following snippet shows how to setup the client to send and receive messages using SignalR.

The HubConnectionBuilder needs to get injected, which must be registered:
```c#
var connection = new HubConnectionBuilder()
// in Startup.cs, ConfigureServices()
services.AddTransient<HubConnectionBuilder>();
```
```c#
// in Component class
[Inject]
private HubConnectionBuilder _hubConnectionBuilder { get; set; }
```
```c#
// in Component Initialization code
var connection = _hubConnectionBuilder // the injected one from above.
.WithUrl("/myHub", // The hub URL. If the Hub is hosted on the server where the blazor is hosted, you can just use the relative path.
opt =>
{
Expand Down

0 comments on commit 9e9923a

Please sign in to comment.