Skip to content

A generic invoker to simplify JavaScript to C# interaction

License

Notifications You must be signed in to change notification settings

soenneker/soenneker.blazor.utils.blazorinvoker

Repository files navigation

Soenneker.Blazor.Utils.BlazorInvoker

A generic invoker to simplify JavaScript to C# interaction

BlazorInvoker<TInput> is an encapsulation class designed as a generic invocation point from JS to C#. It's used for 'fire-and-forget' with no return value.

Installation

dotnet add package Soenneker.Blazor.Utils.BlazorInvoker

Usage

C#

var stringInvoker = new BlazorInvoker<string>(async (input) =>
{
    await SomeAsyncOperation(input);
});

JS

dotnetObject.invokeMethodAsync('Invoke', 'JavaScript argument');