feat: add WebContents.ipc (#34959)
This commit is contained in:
parent
bba22ae720
commit
6d859dcd7f
12 changed files with 341 additions and 12 deletions
|
@ -4,6 +4,13 @@ import { IpcMainInvokeEvent } from 'electron/main';
|
|||
export class IpcMainImpl extends EventEmitter {
|
||||
private _invokeHandlers: Map<string, (e: IpcMainInvokeEvent, ...args: any[]) => void> = new Map();
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
|
||||
// Do not throw exception when channel name is "error".
|
||||
this.on('error', () => {});
|
||||
}
|
||||
|
||||
handle: Electron.IpcMain['handle'] = (method, fn) => {
|
||||
if (this._invokeHandlers.has(method)) {
|
||||
throw new Error(`Attempted to register a second handler for '${method}'`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue