Last active
May 27, 2016 00:03
-
-
Save ssreekanth/78d589034a88447c0f1e5efff57a88db to your computer and use it in GitHub Desktop.
electron-connect working example - with '--enable-logging' args passed to electron-connect's start() and restart() calls in gulpfile.js. Refer Quramy/electron-connect#42
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
'use strict'; | |
const electron = require('electron'); | |
const {app} = electron; | |
const {BrowserWindow} = electron; | |
const {client} = require('electron-connect'); | |
let mainWindow; | |
app.on('window-all-closed', function () { | |
app.quit(); | |
}); | |
app.on('ready', function () { | |
console.log(process.argv.join(', ')); | |
console.log('Hello, browser process'); | |
mainWindow = new BrowserWindow({ | |
width: 400, | |
height: 300 | |
}); | |
mainWindow.loadURL('file://' + __dirname + '/index.html'); | |
mainWindow.on('closed', function() { | |
mainWindow = null; | |
}); | |
client.create(mainWindow); | |
}); |
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
'use strict'; | |
var gulp = require('gulp'); | |
var electron = require('electron-connect').server.create(); | |
gulp.task('serve', function () { | |
// Start browser process | |
electron.start("--enable-logging"); | |
// Restart browser process | |
gulp.watch('app.js', function() { | |
electron.restart("--enable-logging"); | |
}); | |
// Reload renderer process | |
gulp.watch(['index.js', 'index.html'], electron.reload); | |
}); | |
gulp.task('default', ['serve']); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Simple example app</title> | |
</head> | |
<body> | |
<h1>Hello, Electron</h1> | |
<script> | |
console.log('Hello, renderer window!'); | |
console.log('electron version: ' + process.versions.electron); | |
</script> | |
</body> | |
</html> |
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
{ | |
"name": "electron-connect-simple-example", | |
"version": "0.0.1", | |
"main": "./app.js", | |
"scripts": { | |
"start": "gulp serve" | |
}, | |
"devDependencies": { | |
"electron-connect": "^0.4.2", | |
"electron-prebuilt": "^1.2.0", | |
"gulp": "^3.9.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
You could see all the console.log messages from both renderer and browser processes appearing on the console. You could also try opening/saving app.js to see electron app restart working just fine with all the logs appearing on the console.
Output shown below -