This repository contains sample code for the following areas:
- Creating a new
BrowserWindow
and how to show and destroy it from theMainProcess
. - Sending data between
RendererProcess
andMainProcess
in Electron app. - Using
IPCRenderer
andIPCMain
objects. - Connecting
Sqlite3
usingKnex
library. - Building and reading queries using
Knex
library.
The shortcut for showing dev tools on windows in Electron is Command
+ Alt
+ I
on MacOS.
When sending data between RenderProcess
and MainProcess
, there are two important code pieces:
IPCMain
andIPCRenderer
BrowserWindow.webContents.send()
WebContents
contains events, etc. for a window. IPC
means inter-process communication. The idea here is events. You can fire an event by using send()
method along with data to pass, and the subscribers listening to it get the data passed.
Also, when I was working with Sqlite3
, I got errors with it not being found. Therefore, I had to install electron-rebuild
dev-dependency and rebuilt the electron
with it by calling npm run rebuild
. package.json
has the setting for the rebuild command.