IPC communication between the frontend and main process (business layer)
ipcRenderer.js
File location
./frontend/src/utils/ipcRenderer.jsContent
javascript
const Renderer = (window.require && window.require('electron')) || window.electron || {};
/**
* ipc
* Official API documentation: https://www.electronjs.org/docs/latest/api/ipc-renderer
*
* Properties/Methods
* ipc.invoke(channel, param) - Send asynchronous message (invoke/handle model)
* ipc.sendSync(channel, param) - Send synchronous message (send/on model)
* ipc.on(channel, listener) - Listen to channel, when a new message arrives, call listener
* ipc.once(channel, listener) - Add a one-time listener function
* ipc.removeListener(channel, listener) - Remove a specific listener from the listener queue for a specific channel
* ipc.removeAllListeners(channel) - Remove all listeners, when a channel is specified, only remove all listeners associated with it
* ipc.send(channel, ...args) - Send asynchronous message to main process via channel
* ipc.postMessage(channel, message, [transfer]) - Send message to main process
* ipc.sendTo(webContentsId, channel, ...args) - Send message via channel to the window with webContentsId
* ipc.sendToHost(channel, ...args) - Message will be sent to the <webview> element on the host page
*/
/**
* ipc
*/
const ipc = Renderer.ipcRenderer || undefined;
/**
* Whether it is an EE environment
*/
const isEE = ipc ? true : false;
export {
Renderer, ipc, isEE
};API
ipc
Equals the official Electron API
isEE
Whether it is an EE environment. You can use this property to distinguish whether the frontend page is in a server environment or a user's computer environment.
