1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-26 17:08:33 +01:00

move electron renderer messaging service to jslib

This commit is contained in:
Kyle Spearrin 2018-04-25 09:00:58 -04:00
parent 0ad2c9d667
commit 31bd1f9423

View File

@ -0,0 +1,21 @@
import { ipcRenderer } from 'electron';
import { MessagingService } from '../../abstractions/messaging.service';
import { BroadcasterService } from '../../angular/services/broadcaster.service';
export class ElectronRendererMessagingService implements MessagingService {
constructor(private broadcasterService: BroadcasterService) {
ipcRenderer.on('messagingService', async (event: any, message: any) => {
if (message.command) {
this.send(message.command, message);
}
});
}
send(subscriber: string, arg: any = {}) {
const message = Object.assign({}, { command: subscriber }, arg);
ipcRenderer.send('messagingService', message);
this.broadcasterService.send(message);
}
}