This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override async Task OnInitializedAsync() | |
{ | |
var tokenResult = await _tokenProvider.RequestAccessToken(); | |
tokenResult.TryGetToken(out var token); | |
_hubConnection = new HubConnectionBuilder() | |
.WithUrl(_navigationManager.ToAbsoluteUri("https://localhost:6001/customer/orderhub"), options => | |
{ | |
options.AccessTokenProvider = () => Task.FromResult(token.Value); | |
}) | |
.Build(); | |
_hubConnection.On("OrderBeingPrepared", async () => | |
{ | |
await GetOrderDetails(); | |
StateHasChanged(); | |
}); | |
_hubConnection.On("OrderPickedUpForDelivery", async () => | |
{ | |
await GetOrderDetails(); | |
StateHasChanged(); | |
}); | |
_hubConnection.On("OrderDelivered", async () => | |
{ | |
await GetOrderDetails(); | |
StateHasChanged(); | |
}); | |
await _hubConnection.StartAsync(); | |
await _hubConnection.InvokeAsync("WatchOrder", OrderId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment