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:
parent
0ad2c9d667
commit
31bd1f9423
21
src/electron/services/electronRendererMessaging.service.ts
Normal file
21
src/electron/services/electronRendererMessaging.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user