$30 off During Our Annual Pro Sale. View Details »

Cross-Platform Desktop Apps with Electron - FluentConf 2018

Cross-Platform Desktop Apps with Electron - FluentConf 2018

Would you like to leverage your HTML, CSS, and JavaScript skills to build cross-platform desktop applications? Electron is an open source application shell created by GitHub, designed to make building great desktop applications easy. You may have already experienced Electron using applications such as Atom, Slack, or Visual Studio Code. In this talk, you will learn its features, how to quickly get started, and tips from my experience building Electron applications.

David Neal

June 14, 2018
Tweet

More Decks by David Neal

Other Decks in Programming

Transcript

  1. View Slide

  2. View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. View Slide

  24. View Slide

  25. Up Ahead
    • What is Electron?
    • Why desktop?
    • Crash course
    • Tips

    View Slide

  26. .NET + Mono + Xamarin
    Pros:
    • Shared .NET code base
    Cons:
    • Xamarin Mac !== Xamarin iOS/Android
    • Native UI is hard
    • Deployment
    • Licensing

    View Slide

  27. View Slide

  28. Electron
    Pros:
    • HTML + CSS + JavaScript
    • Node.js + Chromium
    • No deployment dependencies

    View Slide

  29. View Slide

  30. View Slide

  31. Electron
    Cons:
    • HTML + CSS + JavaScript

    View Slide

  32. History
    • Created by GitHub for Atom
    • Formerly Atom Shell
    • Active since January 2013
    • 1.0 release May 2016
    • Current: 2.0 May 2nd

    View Slide

  33. Electron Features
    • Rapid development
    • Deployment + “silent” updates
    • Native UX
    • Shared code/UI
    • Themes

    View Slide

  34. View Slide

  35. Why Desktop Apps?
    • Offline
    • Printers, devices,
    other local
    hardware
    • On-premises
    • Internal, LOB
    • Edit local files
    • App Store
    • Kiosk
    • Desktop > Intranet
    • Sometimes it “just
    feels right”

    View Slide

  36. Desktop App Ideas
    • Disconnected data entry
    • Editor
    • Time management
    • Media player
    • Email client
    • Messaging, collaboration
    • Kiosk
    • Mapping, route planner
    • Social media client
    • Calendar
    • Bulk media editor
    • File management, backup
    • Document generation,
    reading
    • Audio/video conferencing
    • Games

    View Slide

  37. Atom

    View Slide

  38. Slack

    View Slide

  39. Visual Studio Code

    View Slide

  40. Postman

    View Slide

  41. GitHub Desktop

    View Slide

  42. View Slide

  43. View Slide

  44. View Slide

  45. View Slide

  46. View Slide

  47. View Slide

  48. ( main.js )

    View Slide

  49. ( main.js )

    View Slide

  50. ( main.js )
    ( index.html )

    View Slide

  51. ( main.js )
    ( home.html )
    ( editor.html )
    ( settings.html )

    View Slide

  52. View Slide

  53. main.js

    View Slide

  54. main.js

    View Slide

  55. main.js

    View Slide

  56. main.js

    View Slide

  57. main.js

    View Slide

  58. main.js

    View Slide

  59. main.js

    View Slide

  60. main.js

    View Slide

  61. index.html

    View Slide

  62. index.html
    > electron main.js

    View Slide

  63. index.html

    View Slide

  64. index.html

    View Slide

  65. index.html

    View Slide

  66. index.html

    View Slide

  67. index.html

    View Slide

  68. index.html

    View Slide

  69. index.html

    View Slide

  70. index.html

    View Slide

  71. View Slide

  72. main.js

    View Slide

  73. main.js

    View Slide

  74. View Slide

  75. View Slide

  76. View Slide

  77. View Slide

  78. View Slide

  79. View Slide

  80. View Slide

  81. View Slide

  82. Process modules
    • app
    • ipc
    • dialog
    • menu, menu-item
    • power-monitor
    • tray

    View Slide

  83. Render modules
    • ipc
    • remote
    • web-frame

    View Slide

  84. Modules available to both
    • clipboard
    • crash-reporter
    • native-image
    • screen
    • shell

    View Slide

  85. Deploying Electron

    View Slide

  86. Deploying Electron

    View Slide

  87. Deploying Electron

    View Slide

  88. Deploying Electron

    View Slide

  89. Deploying Electron

    View Slide

  90. Recommended Tools
    • electron-debug
    • electron-reload
    • electron-mocha

    View Slide

  91. Devtron

    View Slide

  92. View Slide

  93. Boilerplate Projects
    • electron-boilerplate
    • electron-react-boilerplate
    • angular-electron
    • electron-vue

    View Slide

  94. electron-prebuilt-compile
    • ES7 (Babel), TypeScript, GraphQL
    • React.js
    • LESS, Sass/SCSS, Stylus
    • Jade
    • Vue components

    View Slide

  95. View Slide

  96. photonkit.com

    View Slide

  97. View Slide

  98. Tips
    • Use CSS default cursor
    • Keep windows open
    • Offload work to main over ipc

    View Slide

  99. Local Storage
    • Read/write .json files
    – Pro tip: use fs-jetpack
    • nedb
    • pouchdb

    View Slide

  100. Relational DB Storage
    • seriate (SQL Server)
    • pg
    • mysql
    • oracledb

    View Slide

  101. From here…
    https://github.com/sindresorhus/awesome-electron
    Pluralsight: “Electron Fundamentals” by Jake Trent
    http://electron.atom.io
    http://atom-slack.herokuapp.com/

    View Slide

  102. View Slide

  103. View Slide

  104. View Slide