forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-electron.ipc-main.d.ts
36 lines (32 loc) · 1.26 KB
/
github-electron.ipc-main.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Type definitions for Electron v0.37.2
// Project: http://electron.atom.io/
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="github-electron.event-emitter.d.ts" />
/// <reference path="github-electron.web-contents.d.ts" />
declare namespace Electron {
/**
* The ipcMain module handles asynchronous and synchronous messages
* sent from a renderer process (web page).
* Messages sent from a renderer will be emitted to this module.
*/
class IpcMain extends EventEmitter {
addListener(channel: string, listener: IpcMainEventListener): this;
on(channel: string, listener: IpcMainEventListener): this;
once(channel: string, listener: IpcMainEventListener): this;
removeListener(channel: string, listener: IpcMainEventListener): this;
removeAllListeners(channel?: string): this;
}
type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void;
interface IpcMainEvent {
/**
* Set this to the value to be returned in a synchronous message.
*/
returnValue?: any;
/**
* Returns the webContents that sent the message, you can call sender.send
* to reply to the asynchronous message.
*/
sender: WebContents;
}
}