Electron Fundamentals, v2 Electron Fundamentals, v2

Dialog Meets Renderer Exercise

Check out a free preview of the full Electron Fundamentals, v2 course:
The "Dialog Meets Renderer Exercise" Lesson is part of the full, Electron Fundamentals, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to require Electron's remote module, require the main process JavaScript file, and add an event listener that calls a function when a button is clicked.

Get Unlimited Access Now

Transcript from the "Dialog Meets Renderer Exercise" Lesson

>> Steve Kinney: So here is your job, here's our first exercise. We've seen the code, I'll put it back on the screen in a second, but we can use the remote module to touch the main process. We're exporting the getFileFromUser from the main process. So instead of alerting, when the user clicks that button, what we really wanna do now is we wanna call mainprocess.remote.

[00:00:23] I'm sorry, mainprocess.getFileFromUser, and that will trigger the file dialog when someone opens that button. We don't know how to send the file content from the main process to the renderer process yet, but our main goal right now is to go ahead, and at least trigger that file dialog.

[00:00:41] So when they hit the Open File button, they can go ahead, and they can see the dialog, select the file, they'll still get logged to the council now. But our next mission after that will be to go ahead and figure out how to actually read it in the application.

[00:00:58] I will go ahead and create a branch called Live Coding and push it up very shortly.