Interoply 0.1.1
dotnet add package Interoply --version 0.1.1
NuGet\Install-Package Interoply -Version 0.1.1
<PackageReference Include="Interoply" Version="0.1.1" />
<PackageVersion Include="Interoply" Version="0.1.1" />
<PackageReference Include="Interoply" />
paket add Interoply --version 0.1.1
#r "nuget: Interoply, 0.1.1"
#:package Interoply@0.1.1
#addin nuget:?package=Interoply&version=0.1.1
#tool nuget:?package=Interoply&version=0.1.1
Interoply
Interoply is a lightweight, extensible library that makes JavaScript interop in Blazor simple, intuitive, and plug-and-play.
It handles browser events like resize, scroll, visibility, and even custom DOM events — so you don't have to write any JavaScript.
✨ Features
- ✅ Listen to native browser events (
resize,scroll,visibilitychange, etc.) - 🔄 Register to custom DOM events on any element (Soming soon)
- ✅ Extend functionality with C#-only base services (zero JS knowledge required)
- ✅ Automatic cleanup & no JS interop errors during prerender
- ✅ Supports Blazor Server and WebAssembly
📦 Installation
dotnet add package Interoply
🛠️ Getting Started
1. Register Interoply
builder.Services.AddInteroply();
2. Use in your component
@inject IInteroplyService Interoply
<p>Window width: @width px</p>
@code {
private int width;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Interoply.RegisterOnResizeListnerAsync(UpdateWidth);
}
}
ValueTask UpdateWidth(int w)
{
width = w;
StateHasChanged();
return ValueTask.CompletedTask;
}
}
🔌 Write your own service
Interoply provides a base service InteroplyServiceBase — you can write your own services entirely in C#:
public class ToastService : InteroplyServiceBase, IToastService
{
protected override string JsModulePath => "./toast.js";
public ToastService(IJSRuntime jsRuntime)
: base(jsRuntime)
{ }
public async ValueTask ShowToastAsync(string message)
{
await InvokeVoidAsync("showAlert", message);
}
}
Note:
You need to add the JavaScript file toast.js to your project under wwwroot folder with the following content:
export function showAlert(message) {
return alert(message);
}
And register it like this:
builder.Services.AddInteroply();
builder.Services.AddScoped<IToastService, ToastService>();
⚙️ Supported Events
| Event | Method |
|---|---|
| Window Resize | OnResizeAsync(Func<int, ValueTask>) |
| Scroll | OnScrollAsync(Func<double, ValueTask>) |
| Visibility Change | OnVisibilityChangeAsync(Func<bool, ValueTask>) |
| Online/Offline Status | OnOnlineStatusChangeAsync(Func<bool, ValueTask>) |
| Custom DOM Events (Coming soon) | OnDomEventAsync(elementId, eventName, callback) |
💡 Why Interoply?
Blazor is powerful — but JavaScript interop can be painful. Interoply takes care of:
- 🔄 Bridging between JS and C# automatically
- 🧹 Cleanup to prevent memory leaks
- 🔧 Extensibility via base services
- 😌 Simplifying your codebase
📝 License
License © 2025 Mabrouk Mahdhi
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.20)
- Xeption (>= 2.8.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.14)
- Xeption (>= 2.8.0)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.6)
- Xeption (>= 2.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated Dependency Injection Packages to 9.0.6