Class ModuleJsInteropBase
- Namespace
- BlazOrbit.Abstractions
- Assembly
- BlazOrbit.Core.dll
Represents a base class for JavaScript interop modules that implement the IAsyncDisposable interface.
public abstract class ModuleJsInteropBase
- Inheritance
-
objectModuleJsInteropBase
- Derived
Constructors
ModuleJsInteropBase(IJSRuntime, string)
Initializes a new instance of the ModuleJsInterop class.
public ModuleJsInteropBase(IJSRuntime jsRuntime, string jsModuleContentPath)
Parameters
jsRuntimeIJSRuntimeThe JavaScript runtime.
jsModuleContentPathstringThe path to the JavaScript module content.
Exceptions
- ArgumentNullException
Thrown when jsRuntime is null.
Fields
JsRuntime
Represents an interface for invoking JavaScript code from .NET code.
protected readonly IJSRuntime JsRuntime
Field Value
- IJSRuntime
ModuleTask
A lazy asynchronous task that represents a JavaScript object reference.
protected readonly Lazy<Task<IJSObjectReference>> ModuleTask
Field Value
- Lazy<Task<IJSObjectReference>>
Methods
DisposeAsync()
Asynchronously disposes of the resources used by the module. The following exceptions are swallowed intentionally - all four are raised on non-actionable teardown paths (prerender without a circuit, circuit shutdown, runtime disposal, or cancellation during the awaited module dispose).
public virtual ValueTask DisposeAsync()
Returns
- ValueTask
A System.Threading.Tasks.ValueTask representing the asynchronous operation.
TryGetModuleAsync()
First-access module loader hardened against the 5-tuple of terminal failures:
Microsoft.JSInterop.JSDisconnectedException, System.ObjectDisposedException,
System.InvalidOperationException, System.Threading.Tasks.TaskCanceledException, and the
load-specific Microsoft.JSInterop.JSException (404, parse error, module-side throw). Returns
null on failure so call sites can early-out cleanly instead of
duplicating the try/catch boilerplate. Use this in preference to await ModuleTask.Value
for non-disposal call paths; the dispose path intentionally swallows only the 4-tuple per
the contract in DisposeAsync().
protected ValueTask<IJSObjectReference?> TryGetModuleAsync()
Returns
- ValueTask<IJSObjectReference>