Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing information between js and html parts in electron (atom-shell)

Tags:

electron

According to the tutorial, there are two parts of an electron app - the entry main.js file and index.html.

  1. Do I have to include main.js as a script in the html file
  2. How do I trigger events in the view html file to affect the state of the js app and vice versa ? How do they both communicate basically ?
like image 629
Michael Avatar asked May 07 '15 16:05

Michael


1 Answers

You are mixing up a couple of things.

main.js is the first file called when your run your application. Before everything else. It does not run any front-end code.

Usually, in it, you create with the BrowserWindow API a chromium window, then load an .html file in it. (index.html for example).

Then, your index.html, you can call for every front JS code you want, or CSS or whatever. For example you can add there a <script src="myapp.js"></script>, which will run front-end code.

It is important to understand the difference between the main process (back-end) and the render process (front-end).

See the quick start guide that explains that very well.

like image 179
martpie Avatar answered Nov 02 '22 19:11

martpie