Top Banner
Electron, solving our cross-platform* dreams? FOSDEM 2017 @chrischinch *Desktop
19

Electron - Solving our cross platform dreams?

Feb 11, 2017

Download

Technology

Chris Ward
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Electron - Solving our cross platform dreams?

Electron, solving our cross-platform* dreams?

FOSDEM 2017 @chrischinch *Desktop

Page 2: Electron - Solving our cross platform dreams?

–Sun Microsystems, 1995

“Write once, run anywhere”

Page 3: Electron - Solving our cross platform dreams?
Page 4: Electron - Solving our cross platform dreams?
Page 5: Electron - Solving our cross platform dreams?
Page 6: Electron - Solving our cross platform dreams?

Enter Electron

Page 7: Electron - Solving our cross platform dreams?

Use any of these?

Page 8: Electron - Solving our cross platform dreams?

What is it?

• From GitHub*

• JavaScript as a ‘desktop’ Application

• Version 1.5 released last week

*You might have heard of them

Page 9: Electron - Solving our cross platform dreams?

Install and Setup

npm install -g electron

npm install electron —save-dev

brew install Caskroom/cask/electron

Page 10: Electron - Solving our cross platform dreams?

For GUI fans

Page 11: Electron - Solving our cross platform dreams?

For CLI fans

electron .

Page 12: Electron - Solving our cross platform dreams?

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 13: Electron - Solving our cross platform dreams?

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 14: Electron - Solving our cross platform dreams?

The app

Page 15: Electron - Solving our cross platform dreams?

Packaging

• Create asar archive

• Copy files into Electron app

• Rename, distribute, etc…

• Use 3rd party tool 👍

Page 16: Electron - Solving our cross platform dreams?

Electron Packager

electron-packager

/Users/chrisward/Workspace/sp_electron MarvelBrowse

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

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

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

Page 17: Electron - Solving our cross platform dreams?

Going native

• Notifications

• Recent documents

• Menus

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

Page 18: Electron - Solving our cross platform dreams?

Negatives

• Application size

• CPU

• Memory

• Not-native

• Platform inconsistencies

Page 19: Electron - Solving our cross platform dreams?

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

I have stickers and merchandise!