Quick Tip: Fun with Electron

Have you tried out the Atom editor? It has some nice features as far as editors go, however one of the most interesting things about is the fact that it uses atom-shell, which is now called Electron. Electron is a built on node.js. What does that even mean? That means we have transitioned from JavaScript in the browser, to JavaScript in the server to JavaScript on your desktop. With Electron, you can now write and distribute desktop applications written entirely in JavaScript. It’s reminiscent of what Adobe AIR was for Flash, without the plugin requirements.

I’ve been playing around with Electron a bit to just get my feet wet. It has some really neat features. Technically, you can add a Browser Window, disable node support for the window and just copy paste your JavaScript application and be up and running with a web app in Electron.

Yeah, that’s right, you can have a web app with built-in node support. This means you have access to all the normal node stuff you’d expect, file system as well as other modules you might add via npm. So if you were to add Leaflet and Esri-Leaflet as npm modules, you could just write some code like this and it would work.

[gist id=05ad9e876d4942ccbb84]

The code to start the app is just taken from the docs.

I did have some issues trying to request GeoJSON data from an external service and load it into the map. If I happen to figure this out, I’ll post an update.

I put this quick sample on github if you want to try it out. I’m still playing around with Electron, mixing node and non-node environments. The cool part here is you can spawn new process, ala web workers, to handle some heavy lifting for you. A very nice sample app I found while digging around was this one that can preview local GeoJSON files.