bitwarden-estensione-browser/src/electron/services/electronMainMessaging.servi...

16 lines
580 B
TypeScript
Raw Normal View History

2018-04-26 21:43:59 +02:00
import { MessagingService } from '../../abstractions/messaging.service';
import { WindowMain } from '../window.main';
export class ElectronMainMessagingService implements MessagingService {
constructor(private windowMain: WindowMain, private onMessage: (message: any) => void) { }
send(subscriber: string, arg: any = {}) {
const message = Object.assign({}, { command: subscriber }, arg);
this.onMessage(message);
if (this.windowMain.win != null) {
this.windowMain.win.webContents.send('messagingService', message);
}
}
}