Created
May 11, 2016 07:47
-
-
Save sommereder/638e63b5695702b793845c3a29328dac to your computer and use it in GitHub Desktop.
IPC Renderer Service for Electron/Angular2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const electron = require('electron'); | |
// below is just plain angular stuff | |
System | |
.config({ | |
packages: { | |
angular: { | |
format: 'register', | |
defaultExtension: 'js' | |
} | |
} | |
}) | |
; | |
System | |
.import('./angular/main.js') | |
.then(null, console.error.bind(console)) | |
; | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from 'angular2/core'; | |
declare var electron:any; | |
@Injectable() | |
export class IpcRendererService { | |
ipcRenderer = electron.ipcRenderer; | |
// CONSTRUCTOR //////////////////////////////////////////////////////////////////////////////////////////////////// | |
constructor() {} | |
// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////////////////////////////////////////// | |
// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////////////////////// | |
on(message:string, callback) { | |
return this.ipcRenderer.on(message, callback); | |
} | |
send(message:string, ...args) { | |
this.ipcRenderer.send(message, args); | |
} | |
sendSync(message:string, ...args) { | |
return this.ipcRenderer.sendSync(message, arguments); | |
} | |
// EVENT HANDLER ////////////////////////////////////////////////////////////////////////////////////////////////// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in the sendSync method arguments is passed for ipcRenderer.sendSync() , is that a typo or intentional. Should it be args?