public BlazorWebAssemblyBlogNotificationService(NavigationManager navigationManager) { _navigationManager = navigationManager; _hubConnection = new HubConnectionBuilder().AddJsonProtocol(options => { options.PayloadSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve; options.PayloadSerializerOptions.PropertyNamingPolicy = null; }) .WithUrl(navigationManager.ToAbsoluteUri("/BlogNotificationHub")) .Build(); _hubConnection.On <BlogPost>("BlogPostChanged", (post) => { BlogPostChanged?.Invoke(post); }); _hubConnection.StartAsync(); }
public Task SendNotification(BlogPost post) { BlogPostChanged?.Invoke(post); return(Task.CompletedTask); }