Soenneker.Blazor.Utils.ModuleImport
2.1.11
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Soenneker.Blazor.Utils.ModuleImport --version 2.1.11
NuGet\Install-Package Soenneker.Blazor.Utils.ModuleImport -Version 2.1.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Blazor.Utils.ModuleImport" Version="2.1.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Blazor.Utils.ModuleImport --version 2.1.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Blazor.Utils.ModuleImport, 2.1.11"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Soenneker.Blazor.Utils.ModuleImport as a Cake Addin
#addin nuget:?package=Soenneker.Blazor.Utils.ModuleImport&version=2.1.11
// Install Soenneker.Blazor.Utils.ModuleImport as a Cake Tool
#tool nuget:?package=Soenneker.Blazor.Utils.ModuleImport&version=2.1.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Soenneker.Blazor.Utils.ModuleImport
A Blazor utility library assisting with asynchronous module loading
This library simplifies the process of loading JavaScript modules and provides methods for waiting until a module is loaded and disposing of modules when they are no longer needed.
Features
- Import JavaScript modules dynamically.
- Wait until a module is fully loaded.
- Dispose of JavaScript modules when they are no longer needed.
- Singleton pattern to ensure that each module is loaded only once.
Installation
To install, add the package to your Blazor project using the .NET CLI:
dotnet add package Soenneker.Blazor.Utils.ModuleImport
Register it in DI:
builder.Services.AddModuleImportUtil();
Example
Here's an example of how to use the ModuleImportUtil
in a Blazor component:
@page "/example"
@inject IModuleImportUtil ModuleImportUtil
@implements IAsyncDisposable
<h3>Module Import Example</h3>
<button @onclick="LoadModule">Load Module</button>
@code {
private async Task LoadModule()
{
var module = await ModuleImportUtil.Import("exampleModule");
await ModuleImportUtil.WaitUntilLoaded("exampleModule");
// Guaranteed that the module has been added to the DOM, and available at this point
}
public async ValueTask DisposeAsync()
{
await ModuleImportUtil.DisposeModule("exampleModule");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.JSInterop (>= 8.0.6)
- Soenneker.Blazor.Utils.JsVariable (>= 2.1.5)
- Soenneker.Utils.SingletonDictionary (>= 2.1.306)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Blazor.Utils.ModuleImport:
Package | Downloads |
---|---|
Soenneker.Blazor.Utils.ResourceLoader
A Blazor JavaScript interop for dynamically loading scripts, styles, and modules |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.17 | 28 | 6/30/2024 |
2.1.16 | 52 | 6/30/2024 |
2.1.15 | 37 | 6/30/2024 |
2.1.14 | 25 | 6/30/2024 |
2.1.13 | 23 | 6/30/2024 |
2.1.12 | 78 | 6/30/2024 |
2.1.11 | 121 | 6/28/2024 |
2.1.10 | 33 | 6/28/2024 |
2.1.9 | 65 | 6/28/2024 |
2.1.8 | 45 | 6/28/2024 |
2.1.7 | 71 | 6/27/2024 |
2.1.6 | 52 | 6/27/2024 |
2.1.5 | 30 | 6/27/2024 |
2.1.4 | 179 | 6/27/2024 |
2.1.3 | 241 | 6/23/2024 |
2.1.2 | 53 | 6/23/2024 |
2.1.1 | 56 | 6/23/2024 |