2017-04-16 02:27:06 +09:00
|
|
|
import log from './log';
|
|
|
|
import r from './require';
|
|
|
|
const electron = r('electron');
|
|
|
|
const ipc = electron.ipcRenderer;
|
|
|
|
|
2017-04-19 17:07:31 +09:00
|
|
|
export function on(channel: IpcChannelFromMain, callback: (...args: any[]) => void) {
|
2017-04-20 01:32:18 +09:00
|
|
|
ipc.on(channel, (_, ...args: any[]) => {
|
2017-04-17 18:40:55 +09:00
|
|
|
log.info('IPC: Received from:', channel, args);
|
2017-04-16 02:27:06 +09:00
|
|
|
callback(...args);
|
|
|
|
});
|
|
|
|
}
|
2017-04-19 17:07:31 +09:00
|
|
|
|
|
|
|
export function send(channel: IpcChannelFromRenderer, ...args: any[]) {
|
|
|
|
log.info('IPC: Send:', channel, args);
|
|
|
|
ipc.send(channel, ...args);
|
|
|
|
}
|