Blazor
Blazor is a .NET frontend web framework that supports both server-side rendering and client interactivity in a single programming model
builder.Services.AddShinyMediator(cfg => cfg.UseMaui());
- Start making calls to the mediator as you normally would
Event Collector
Section titled “Event Collector”The Blazor event collector is installed by default by UseBlazor
. Event collectors allow event handlers that may not be registered with dependency injection/Mediator
to still participate in IMediator.Publish
calls.
Middleware Support
Section titled “Middleware Support”This extension comes with a lot of preinstalled default middleware (that you can opt out of). If you choose to opt-out of this middleware being installed,
simply pass false to the first argument in UseMaui
Connectivity Broadcaster
Section titled “Connectivity Broadcaster”Connectivity is used on almost every page or viewmodel in an app. You almost always have to inject the a connectivity service and hook the StateChanged event to do things like disabling buttons, showing errors, or putting up an banner to let you users know why your app isn’t showing fresh data. That’s a lot of extra code, cleanup, hooks, etc. This is where connectivity broadcaster comes in
-
In your main lastout, add the
<InternetConnectivity />
component<InternetConnectivity /> -
In your pages, controls (in scope of current page), or services, implement the
IConnectivityEventHandler
interfacepublic class MyService : Shiny.Mediator.IConnectivityEventHandler{public async Task Handle(ConnectivityChanged @event, IMediatorContext context, CancellationToken ct){// that's itSomeString = @event.Connected ? "Connected" : "Disconnected";}}OR
@implements Shiny.Mediator.IConnectivityEventHandler@code {public async Task Handle(ConnectivityChanged @event, IMediatorContext context, CancellationToken ct){// that's itSomeString = @event.Connected ? "Connected" : "Disconnected";await InvokeAsync(StateHasChanged);}}