Open autoprog opened 11 months ago
hi, try register functions
protected async override Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
{
Console.WriteLine("Load modules ok" );
dotNetObjectReference = DotNetObjectReference.Create(this);
await jSRuntime.InvokeVoidAsync("mqttFunctions.createClient", dotNetObjectReference);
dotNetObjectReference = DotNetObjectReference.Create(this);
await jSRuntime.InvokeVoidAsync("mqttFunctions.connect", dotNetObjectReference);
dotNetObjectReference = DotNetObjectReference.Create(this);
await jSRuntime.InvokeVoidAsync("mqttFunctions.disconnect", dotNetObjectReference);
dotNetObjectReference = DotNetObjectReference.Create(this);
await jSRuntime.InvokeVoidAsync("mqttFunctions.publish", dotNetObjectReference);
}
}
///----------log
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit 'ztfUHAJzUGP7Kr_ORH_dhB7rBTV6qalNn4z4-mrQQgY'.
Microsoft.JSInterop.JSException: Paho is not defined
ReferenceError: Paho is not defined
at Object.createClient (http://localhost:5155/scripts/paho-mqtt-interop.js:16:9)
at http://localhost:5155/_framework/blazor.server.js:1:3501
at new Promise (
hi, the design as this works ok. I create a new project, with .Net6 client or server mode, gives errors in JsInterop, I tried to solve it but it's complicated. I would like to receive help to register this functions to inject javacript. I'm trying to do it like this: protected override async Task OnInitializedAsync() protected async override Task OnAfterRenderAsync(bool firstRender).
as I saw some examples, but without success until then.
Blazor, at first I want a PWA App, but it can be MVC to resolve.
thanks, Carlos.