Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding and calling custom javscript to electron .net app #783

Closed
domingoladron opened this issue Jun 18, 2023 · 2 comments
Closed

Adding and calling custom javscript to electron .net app #783

domingoladron opened this issue Jun 18, 2023 · 2 comments
Assignees
Labels

Comments

@domingoladron
Copy link

Hey there,

I want to hook right into the electron engine via Javascript using npm etc. How do I

  1. Add code which should be loaded and run by the base electron system?
  2. Ensure this code is loaded up when the app is built / started?
  3. Call such custom code from the electron.net APIs?

I have been trying to piece it all together, but so many moving parts and I just would like a bit of clarity so I can do this right.

Cheers

@GregorBiswanger
Copy link
Member

For this, we have the HostHook feature, which needs to be activated via the Electron.NET-CLI with the following command: electronize add hosthook

This will create an ElectronHostHook directory in your project. Ideally, you can now open this with Visual Studio Code. Install NPM packages and communicate with the actual application.

Our Electron.NET API Demo App and its source code will show you exactly how to do this:
https://github.com/ElectronNET/electron.net-api-demos

https://github.com/ElectronNET/electron.net-api-demos/blob/master/ElectronNET-API-Demos/Controllers/HostHookController.cs

https://github.com/ElectronNET/electron.net-api-demos/tree/master/ElectronNET-API-Demos/ElectronHostHook

Was I able to assist you with this?

@domingoladron
Copy link
Author

That's exactly what I was after. Thanks so much.

Once I get my head around it and am able to do the basics, would y'all be amenable to a documentation PR with details on how to do this for others? This seems like a useful scenario for devs, as some stuff is just easier to do in javascript / typescript / electron than in Blazor.

If a documentation PR would be acceptable, do you have a preferred place (README.md?) for such docs?

Let me know and cheers for the assist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants