mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
main messaging service to jslib
This commit is contained in:
15
src/electron/services/electronMainMessaging.service.ts
Normal file
15
src/electron/services/electronMainMessaging.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user