/apprun-electron

Primary LanguageTypeScriptMIT LicenseMIT

Using AppRun in Electron App

This is a demo of using AppRun in the Electron app.

Send message from the main process

Click the menu 'Hello' to send a message.

mainWindow.webContents.send('@apprun', '#hello', 'from Electron Main');

The AppRun component, main.tsx, receives the message.

  update = {
    '#hello': (_, msg) => msg
  }

Send message from the renderer process

Click the button 'Hello to Electron main process' to send a message.

app.run('@electron', 'hello', 'from', 'Renderer');

The Electron app receives and prints the message.

ipcMain.on('@electron', (_, ...arg) => {
  console.log(...arg);
});

Development

  • Use npm run dev to start the dev watch
  • Use npm start to start Electron
  • Use npm run build to build for production