Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle duplicate ipcMain.on methods after multiple Windows of the same instance? #87

Open
yyccQQu opened this issue Jun 13, 2022 · 0 comments

Comments

@yyccQQu
Copy link

yyccQQu commented Jun 13, 2022

at renderer code

let { dialog, app } = remote;
ipcRenderer.send("close-win", "111");

at main code

ipcMain.on("close-win", (e, arg) => {
  console.log('win: ', arg)
})

when i use this method create more windows, There are four Windows, and as soon as the close-win of one of them is triggered, the close-win receive of the main process is repeated four times

function createWindow(mainWindow, devPath = "", prodPath = "index.html", winNum) {
   winNum++
   mainWindow = windowManager.createNew(
        multipleName,
        multipleName,
        winURL,
        false,
        winObj,
        isDev
    );
  mainWindow.create();
}


let mainWindowF;
createWindow(mainWindowF)

Result
the main code result is

win:  111
win:  111
win:  111
win:  111

But I only want to trigger it once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant