mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Merge pull request #7374 from hinamiyagk/electron-ipc-event
Add type definition for IPC Event on main process
This commit is contained in:
@@ -275,12 +275,12 @@ globalShortcut.unregisterAll();
|
||||
// ipcMain
|
||||
// https://github.com/atom/electron/blob/master/docs/api/ipc-main-process.md
|
||||
|
||||
ipcMain.on('asynchronous-message', (event: any, arg: any) => {
|
||||
ipcMain.on('asynchronous-message', (event: GitHubElectron.IPCMainEvent, arg: any) => {
|
||||
console.log(arg); // prints "ping"
|
||||
event.sender.send('asynchronous-reply', 'pong');
|
||||
});
|
||||
|
||||
ipcMain.on('synchronous-message', (event: any, arg: any) => {
|
||||
ipcMain.on('synchronous-message', (event: GitHubElectron.IPCMainEvent, arg: any) => {
|
||||
console.log(arg); // prints "ping"
|
||||
event.returnValue = 'pong';
|
||||
});
|
||||
|
||||
Vendored
+19
-1
@@ -1464,6 +1464,24 @@ declare module GitHubElectron {
|
||||
sendToHost(channel: string, ...args: any[]): void;
|
||||
}
|
||||
|
||||
class IPCMain implements NodeJS.EventEmitter {
|
||||
addListener(event: string, listener: Function): IPCMain;
|
||||
once(event: string, listener: Function): IPCMain;
|
||||
removeListener(event: string, listener: Function): IPCMain;
|
||||
removeAllListeners(event?: string): IPCMain;
|
||||
setMaxListeners(n: number): IPCMain;
|
||||
getMaxListeners(): number;
|
||||
listeners(event: string): Function[];
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
listenerCount(type: string): number;
|
||||
on(event: string, listener: (event: IPCMainEvent, ...args: any[]) => any): IPCMain;
|
||||
}
|
||||
|
||||
interface IPCMainEvent {
|
||||
returnValue?: any;
|
||||
sender: WebContents;
|
||||
}
|
||||
|
||||
interface Remote extends CommonElectron {
|
||||
/**
|
||||
* @returns The object returned by require(module) in the main process.
|
||||
@@ -1761,7 +1779,7 @@ declare module GitHubElectron {
|
||||
BrowserWindow: typeof GitHubElectron.BrowserWindow;
|
||||
contentTracing: GitHubElectron.ContentTracing;
|
||||
dialog: GitHubElectron.Dialog;
|
||||
ipcMain: NodeJS.EventEmitter;
|
||||
ipcMain: GitHubElectron.IPCMain;
|
||||
globalShortcut: GitHubElectron.GlobalShortcut;
|
||||
Menu: typeof GitHubElectron.Menu;
|
||||
MenuItem: typeof GitHubElectron.MenuItem;
|
||||
|
||||
Reference in New Issue
Block a user