I started this week knowing nothing about Ember or Electron. So, naturally, I set out to make an app using both.
The Ember stack includes:
- Ember CLI: Build tools and command line utility. Like Rails, all you have to do is run `ember new app-name` to generate a new app with a standard file and directory structure, a testing framework, dependencies (managed by bower and npm), ES6 syntax support using Babel and asset management for minifying.
- Ember Data: A data-persistence library. Ember Data can save records via a RESTful JSON API without any additional configuration.
- Ember Inspector: An extension for Firefox and Chrome to help developers debug Ember apps.
- Fastboot: An Ember CLI addon to allow developers the ability run their apps in Node.js.
- Liquid Fire: Animation support.
Electron is an open-source framework for desktop GUI applications. Built by Github, Electron used to be known as Atom Shell and is the framework Atom was built with.
Apps built on Electron include Slack, VisualStudio, Avocode, PopKey and GitKraken.
There are two main processes: Main and Renderer. Main creates the web pages by using `BrowserWindow` instances. Renderer is the tool used to display web pages. But, unlike normal browsers, Electron apps have access to native resources. When a `BrowserWindow` instance is destroyed, the renderer process is also stopped.
Ember's philosophy centers around the developer. Its creators used four ideas to drive the design:
- Productivity: Ember provides tools that make getting started fast. Ember CLI provides a standard architecture with countless options for enhancement.
- Stability: Ember's creators and maintainers recognize the importance of backward compatibility while continuing to innovate.
Ember adheres to the Don't Repeat Yourself (DRY) principle and prefers convention over configuration. It is opinionated but flexible, providing developers both freedom and guidance.
Why Ember + Electron?
Well, for one, it seems like it hasn't been done a lot before. That's kinda cool and leaves lots of room to learn through experimentation. (Or pull out my hair in frustration, you know, either way.)
Initially I thought Electron would be the most heavily used because the app would be a desktop app. But again, it's really just a wrapper.
Ember does most of the heavy lifting.
And, I'm sure there are some people who would argue I should have opted for a native app and not used a cross-platform tool like Electron.
While I think there's a time and place for that, right now, I'm focused on learning. And I love that I'll be able to deploy it for any system.
The greatest immediate challenge was getting started. By the end of Monday, my understanding of Ember was about 15% and my knowledge of Electron was maybe 5% — and that's probably stretching it.
I had no idea where to start.
So, here's what I did:
(Warning, Steve Kinney makes a lot of appearances.)
After implementing edit and create on my own program, the flow of Ember started to make more sense. Ember follows an MVC philosophy, but in a very different way than Rails. I still felt unsure of how to pass information around.
One of the features we aimed to complete was a preview of the note (written in Markdown) in HTML, shown in a separate pane.
So how do you get the note into another component?
Here's the code for the note: