Create specialized IJSObjectReference dynamic proxy facades
🏃 Getting Started | 📦 NuGet Package
Teronis.Microsoft.JSInterop.Dynamic Extends the functionality of Microsoft.JSInterop and Teronis.Microsoft.JSInterop. First recommend you to read Teronis.Microsoft.JSInterop. After you know what activators are available I can tell you that every activator has now a dynamic proxy activator too. These activators offers you to create interface proxies.
Package Managaer
Install-Package Teronis.Microsoft.JSInterop.Dynamic -Version <version>
.NET CLI
dotnet add package Teronis.Microsoft.JSInterop.Dynamic --version <version>
Because this project serves as a kompendium of Teronis.Microsoft.JSInterop.Abstractions, Teronis.Microsoft.JSInterop.Core, Teronis.Microsoft.JSInterop.Locality.WebAssets and Teronis.Microsoft.JSInterop.Dynamic.Core it is very simple to get started.
Please take a look at the available facades and their individual activator of Teronis.Microsoft.JSInterop.
This is the entry point of all available dynamic proxy activators listed below. It creates a dynamic proxy that at least implements IJSObjectReferenceFacade.
// Register Services
public void ConfigureServices(IServiceCollection services) =>
services.AddJSDynamicProxy();
// Get Started
public object ProvideService(IServiceProvider serviceProvider) =>
serviceProvider.GetRequiredService<IJSDynamicProxyActivator>();
⚠️ Currently there are default interceptors and value assigners added that requires you to callservices.AddJSDynamicFacadeHub
. When you are not doing it you are running into an exception of missing services when these interceptor and value assigners are created on the fly when you firstly request theIJSDynamicLocalObjectActivator
.
The dynamic proxy facade implements at least IJSModule.
// Register Services
public void ConfigureServices(IServiceCollection services) =>
services.AddJSDynamicModule();
// Get Started
public object ProvideService(IServiceProvider serviceProvider) =>
serviceProvider.GetRequiredService<IJSDynamicModuleActivator>();
⚠️ Currently there are default interceptors and value assigners added that requires you to callservices.AddJSDynamicFacadeHub
. When you are not doing it you are running into an exception of missing services when these interceptor and value assigners are created on the fly when you firstly request theIJSDynamicModuleActivator
.
The dynamic proxy facade implements at least IJSLocalObject.
// Register Services
public void ConfigureServices(IServiceCollection services) =>
services.AddJSDynamicLocalObject();
// Get Started
public object ProvideService(IServiceProvider serviceProvider) =>
serviceProvider.GetRequiredService<IJSDynamicLocalObjectActivator>();
⚠️ Currently there are default interceptors and value assigners added that requires you to callservices.AddJSDynamicFacadeHub
. When you are not doing it you are running into an exception of missing services when these interceptor and value assigners are created on the fly when you firstly request theIJSDynamicLocalObjectActivator
.
// Register Services
public void ConfigureServices(IServiceCollection services) =>
services.AddJSDynamicFacadeHub();
// Get Started
public object ProvideService(IServiceProvider serviceProvider) =>
serviceProvider.GetRequiredService<IJSFacadeHub<JSDynamicFacadeActivators>>(); // JSDynamicFacadeActivators holds all available dynamic and non-dynamic activators.
The above activators are good quick-starters. For bigger scenarios I am currently lacking of comprehensive examples so I have to forward you to some good and self-explanatory unit tests.
- Create an object (component) that holds dynamic modules and dynamic global objects that get initialized when activating
IJSFacadeHub<T>
by invokingIJSCustomFacadeActivator.CreateInstance(object component)
:
/src/Microsoft/JSInterop/Dynamic/0/test/0/Facade/JSDynamicFacadeHubComponentTests.cs - Create local dynamic proxy facades:
/src/Microsoft/JSInterop/Dynamic/0/test/0/Locality - Advanced dynamic proxy usage cases:
/src/Microsoft/JSInterop/Dynamic/0/test/0/Dynamic