BlazorWorker icon indicating copy to clipboard operation
BlazorWorker copied to clipboard

Sample request - BlazorWorker interacting with in-page JavaScript

Open yoDon opened this issue 3 years ago • 1 comments

BlazorWorker looks like a great way to incrementally add some .NET to an existing React/Angular/Vue/jQuery/whatever page or site.

Is there any chance of a tiny Demo where some JS in a page calls a method on a Blazor worker and the Blazor worker calls a JS method on the page?

I see for example BlazorWorker.WorkerCore.MessageService so I'm thinking this is stuff you've already built into BlazorWorker at least at some level, but I'm not spotting how to pull it together into a little sample app.

yoDon avatar May 12 '22 20:05 yoDon

Hello. Blazorworker works primarily with Blazor ( as opposed to React/Angular/Vue/jQuery/whatever) and all examples in the demo apps.

That said, you're not the first person who had this idea, and it's doable. The current code assumes a Blazor frontend, but using the " core example" you should be able to debug and see what kind of messages are being sent to the worker, and the could be constructed using vanilla JavaScript (or React/Angular/Vue/jQuery/whatever).

The build process is based on whatever the Blazor tool chain produces, so in any case a basic Blazor app would have to be built to be able to take advantage of it.

Tewr avatar May 19 '22 10:05 Tewr