I need to build an app that will span across multiple monitor screens, something like this: Electron suports multiple windows but how to comunicate between them?
相关问题
- How can I get a window object from new BrowserWind
- Failed at the electron@1.8.2 postinstall script
- No member named ForceSet
- Export HTMLtable to CSV in electron
- Using electron-usb with electron
相关文章
- Named pipes server read timeout
- Configuring electron-webpack renderer to work with
- Error messages and console logs in Electron?
- Adding Apple in-app purchase to Electron HTML/JS a
- How to using XPath in WebBrowser Control?
- WebBrowser control and Windows 10 issue (Navigatio
- How to call and pass arguments to a JavaScript met
- simple IPC mechanism for C#/WPF application to imp
The main thing to remember is that in Electron, interProcess communication is done by ipcMain (in the main process) and ipcRenderer(in all the created windows). Like below: From what i've seen in the GitHub comments - direct communication between the Renderer instances is not allowed. Everything must pass trough the mainProcess.
the code: mainProcess.js:
window1.html:
window1.js:
window2.html:
window2.js:
A demo would be better, but I don't know how to build an electron CodeBin app. This image gives you an idea:
Enjoy the power of Electron !
Depending on your requirements... it is possible to create SharedWorker that acts as a proxy transferring MessagePorts between windows. Note: SharedWorker requires all windows run from the same origin (might not meet your requirements). So for example, in the main window create a MessageChannel (which has provides two ports), then transfer port1 via the SharedWorker to one window and port2 to the other window. Now the two windows can communicate directly via the ports using postMessage. As a bonus postMessage also supports transferables. I was playing around with the idea but haven't yet fully developed the library but you can get the idea from some work in progress here: https://github.com/lneir/electron-direct-comm
Whenever we talk about communicating from one window to another window inside of an Electron application, you always want to be thinking of the IPC system, Inter Process Communication.
So in one window you will listen for an event, for example, a form submittal.
Once the form is submitted, you can take the text out of that input and emit an event to the Electron app.
Then the Electron app will trigger its own event and send the event on over to the
mainWindow
which will receive the text and append it on to its list.You can start this with just vanilla JavaScript in the secondary window.html file like so:
So the above assumes you are working with a form you are trying to submit.