building cross platform apps with electron

14
Create Amazing Cross- Platform Desktop Node Apps with Electron ViennaJS, June @chrischinch

Upload: chris-ward

Post on 16-Apr-2017

92 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Building Cross Platform Apps with Electron

Create Amazing Cross-Platform Desktop Node Apps with Electron

ViennaJS, June @chrischinch

Page 2: Building Cross Platform Apps with Electron

Use any of these?

Page 3: Building Cross Platform Apps with Electron

What is it?

• From GitHub*

• JavaScript as a ‘desktop’ Application

• Version 1.0 released in May

*You might have heard of them

Page 4: Building Cross Platform Apps with Electron

Install and Setup

npm install electron-prebuilt -g

brew install Caskroom/cask/electron

Page 5: Building Cross Platform Apps with Electron

End result

Page 6: Building Cross Platform Apps with Electron

For GUI fans

Page 7: Building Cross Platform Apps with Electron

For CLI fans

electron .

Page 8: Building Cross Platform Apps with Electron

An Electron project

index.html: The web page rendered by default.

main.js: Starts app and creates a browser window to render HTML.

package.json: Lists application dependencies, meta data and files needed.

Page 9: Building Cross Platform Apps with Electron

main.jsconst electron = require('electron'); const app = electron.app;const BrowserWindow = electron.BrowserWindow;var mainWindow = null; app.on('window-all-closed', function() { if (process.platform != 'darwin') { app.quit(); }});app.on('ready', function() { mainWindow = new BrowserWindow({width: 800, height: 600}); mainWindow.loadURL('file://' + __dirname + '/app/index.html'); mainWindow.on('closed', function() { mainWindow = null; });});

Page 10: Building Cross Platform Apps with Electron

The app

Page 11: Building Cross Platform Apps with Electron

Packaging

• Create asar archive

• Copy files into Electron app

• Rename, distribute, etc…

• Use 3rd party tool 👍

Page 12: Building Cross Platform Apps with Electron

Electron Packager

electron-packager

/Users/chrisward/Workspace/sp_electron MarvelBrowse

--platform=darwin --arch=x64 --asar --prune

—version=1.2.5

--out=/Users/chrisward/Workspace --overwrite

--icon=/Users/chrisward/Workspace/sp_electron/marvel-app.icns

Page 13: Building Cross Platform Apps with Electron

Going native

• Notifications

• Recent documents

• Menus

• Progress bars, thumbnails, represented file, dock, System preferences…

Page 14: Building Cross Platform Apps with Electron

Thank You!Chris Ward gregariousmammal.com @chrischinch Developer Relations & Technical Writer

I have stickers and merchandise!