I was working on a very simple electron app, following a guide on Youtube and the teacher has me put an event listener on a button, like so:
button.addEventListener('click', ()=> {
main.openWindow();
});
Standard stuff. main
is from using Electron's remote module to allow me to grab the exports object off the main js file that runs the electron. openWindow()
is the exported function and it opens an Electron window. And it works.
I thought I'd make it tighter by doing this:
button.addEventListener('click', main.openWindow);
Except I get an error when I click on the button:
Uncaught Error: No such module: atom_common_app
I'm not sure I understand the difference between the first snippet and the second. The first uses an anonymous function that calls my exported function, the other gives the add event listener a reference to that function to use when the button is clicked on. I don't understand why one works and the other does not. What is the difference between the first snippet and the second?
Thanks