Skip to main content

Definition

Assembly: CloudNimble.BlazorEssentials.dll Namespace: CloudNimble.BlazorEssentials Inheritance: System.Object

Syntax

Summary

A wrapper that makes it easier to dynamically import JavaScript modules in Blazor. Can be used as the foundation to build strongly-typed .NET wrappers around JavaScript libraries.

Remarks

I built this because trying to remember the same pattern for importing JS modules in Blazor was driving me nuts.

Constructors

.ctor

Creates a new instance of the JsModule class.

Syntax

Parameters

Remarks

If you don’t provide a modulePath, the constructor will attempt to infer it from the calling assembly, in the format ”../_content//.js”.

.ctor

Creates a new instance of the JsModule class.

Syntax

Parameters

Remarks

The SDK-style project system actually does a really good job of knowing when the PackageId is different from the AssemblyName, so this constructor may not be necessary.

.ctor Inherited

Inherited from object

Syntax

Properties

Instance

Returns a Lazy1](https://learn.microsoft.com/dotnet/api/system.lazy-1) reference to the [Task1 of importing the module through IJSRuntime.

Syntax

Property Value

Type: System.Lazy<System.Threading.Tasks.Task<Microsoft.JSInterop.IJSObjectReference>>

Remarks

We’re using Lazy1](https://learn.microsoft.com/dotnet/api/system.lazy-1) here to ensure that the module is imported exactly once and only when needed. [Lazy1 manages the instance for us

Methods

DisposeAsync

Disposes of

Syntax

Returns

Type: System.Threading.Tasks.ValueTask

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

InvokeAsync

Syntax

Parameters

Returns

Type: System.Threading.Tasks.ValueTask<TValue>

Type Parameters

  • TValue -

InvokeAsync

Syntax

Parameters

Returns

Type: System.Threading.Tasks.ValueTask<TValue>

Type Parameters

  • TValue -

InvokeAsync

Syntax

Parameters

Returns

Type: System.Threading.Tasks.ValueTask<TValue>

Type Parameters

  • TValue -

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?
  • Microsoft.JSInterop.IJSObjectReference
  • System.IAsyncDisposable