ipcMain listener not registering correctly

14
May 18, 2019, at 3:20 PM

Am having some troubles with ipc messages between the main and renderer processes in an electron app.

The ipcRenderer is sending the message correctly (I can see it from devtron) but the ipcMain is not listening to anything

code in main.js

const {ipcMain} = require("electron");
...
let mainWindow;
function createWindow() {
...
  ipcMain.on("mainWindow-minimize", (event, arg) 
  => {
    console.log("On minimize from main");
    mainWindow.minimize();
  });
...
}
app.on("ready", createWindow);

code in renderer.jsx

import React from "react"
impor {ipcRenderer} from "electron"
...
export default class App Extends React.Component {
  constructor(props) {
    super(props);
    this.headerOnClick = this.headerOnClick.bind(this);
  }
  headerOnClick(message, event) {
    console.log("button clicked");
    ipcRenderer.send(message)
  }
  render() {
    return (
      <button onClick={() => this.headerOnClick("mainWindow-minimize", event)} />
    )
  }
}
Answer 1

I think you need to call createWindow function in main so the listener is created.

READ ALSO
Unable to post the data from view to controller in Yii2

Unable to post the data from view to controller in Yii2

I am working on Yii2I have a gridview with checkbox and on a button click I am redirecting it to an action controller using ajax

21
add values of 5 text boxes and show the esult in 6th tetbo on the keypress vent of 5 th textbox

add values of 5 text boxes and show the esult in 6th tetbo on the keypress vent of 5 th textbox

i have 6 text boxes with id a,b,c,d,e,fout of these i enter value for 5

19
react-apollo Server Side Rendering

react-apollo Server Side Rendering

Disclaimer: I saw many other questions on SO which sound the sameBut no, this question and its context, everything is different

43
How detect window closed (new tab) in Vue?

How detect window closed (new tab) in Vue?

Need watch if that window open or closed

16