11

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 ?
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Michael
  • 22,196
  • 33
  • 132
  • 187
  • possible duplicate of [What is the Client/Server model when using Electron (Atom Shell)?](http://stackoverflow.com/questions/24583204/what-is-the-client-server-model-when-using-electron-atom-shell) – Michael May 07 '15 at 17:45
  • I have voted to close this as http://stackoverflow.com/questions/24583204/what-is-the-client-server-model-when-using-electron-atom-shell pretty much led me to the answer. They communicate via some IPC mechanism. Smart, keeps everything decoupled and clean (see https://github.com/atom/electron/blob/master/docs/api/ipc-main-process.md) – Michael May 07 '15 at 17:46

1 Answers1

6

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.

martpie
  • 5,510
  • 1
  • 21
  • 25