Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/surgicalcoder/BlazorInteropGenerator

Generates Blazor -> Javascript strongly typed interop methods.
https://github.com/surgicalcoder/BlazorInteropGenerator

Last synced: 3 months ago
JSON representation

Generates Blazor -> Javascript strongly typed interop methods.

Awesome Lists containing this project

README

        

# BlazorInteropGenerator
Generates Blazor -> Javascript strongly typed interop methods, by parsing the Javascript it self and generating extension methods for IJSRuntime.

## Usage

Firstly, add the project from Nuget - [GoLive.Generator.BlazorInterop](https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/), then add an AdditionalFile in your .csproj named "ApiClientGenerator.json", like so:

```

```

Once that's done, add the settings file and change as required:

```
{
"JavascriptFile": "wwwroot\\assets\\js\\blazorinterop.js",
"JSInit": [
"window={}"
],
"MainJsObject": "window.blazor",
"InvokeVoidString": "await JSRuntime.InvokeVoidAsync(\"{0}\", {1});",
"InvokeString": "return await JSRuntime.InvokeAsync(\"{0}\",{1});"
}

```

The `JSInt` option is there if you need to init a value, such as if you have all of your methods under `window.blazor`, you need to init `window`.