@page "/"
@inject IJSRuntime js
<input type="checkbox" @bind="isGranted" /> Some Permission
@(isGranted?"granted":"not granted")
@code {
bool isGranted;
protected override async Task OnInitAsync() {
await js.InvokeAsync<object>(
"foo.bar",
DotNetObjectRef.Create(this),
nameof(BarCallback)
);
}
[JSInvokable]
public void BarCallback(bool result) {
Console.WriteLine($"BarCallback(result: {result})");
isGranted = result;
}
protected override bool ShouldRender() {
Console.WriteLine("Blazor is checking for re-rendering...");
return true;
}
}