Skip to content

Instantly share code, notes, and snippets.

@etyp
Created September 1, 2015 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etyp/2d9b2f64e845105c4835 to your computer and use it in GitHub Desktop.
Save etyp/2d9b2f64e845105c4835 to your computer and use it in GitHub Desktop.
An example of checking is meteor is running with electron or not
Meteor.isElectron = false;
if (Meteor.isClient) {
Meteor.isElectron = (typeof window.require !== 'undefined');
}
if (Meteor.isElectron) {
console.log("Running on desktop");
var ipc = window.require('ipc');
Template.hello.events({
'click button': function (event) {
// Prevent default browser form submit
//event.preventDefault();
console.log("clicking on button");
// Send ipc event
ipc.send('new-file', { fileName: "name", text: "text" });
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
console.log('Meteors app started.');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment