main messaging service to jslib

This commit is contained in:
Kyle Spearrin 2018-04-26 15:43:59 -04:00
parent 983a7b474c
commit 35039fdae2
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
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);
}
}
}