nft-faucet/NftFaucet/Layouts/BasicLayout.cs

35 lines
771 B
C#

using Microsoft.AspNetCore.Components;
using NftFaucet.Infrastructure.Models.State;
using NftFaucet.Infrastructure.Services;
namespace NftFaucet.Layouts;
public abstract class BasicLayout : LayoutComponentBase
{
[Inject]
protected NavigationManager UriHelper { get; set; }
[Inject]
protected ScopedAppState AppState { get; set; }
[Inject]
protected RefreshMediator RefreshMediator { get; set; }
protected override void OnInitialized()
{
RefreshMediator.StateChanged += async () => await InvokeAsync(StateHasChangedSafe);
}
protected void StateHasChangedSafe()
{
try
{
InvokeAsync(StateHasChanged);
}
catch (Exception)
{
// ignored
}
}
}