Hosting a ember.js application in Electron


#1

I’ve just come across Electron and would like to understand the best way to structure applications. My first thought was to use ember.js as a starting point.

So I’ve really got three questions:

  1. Is ember.js really the best way structure an application inside of electron?

  2. Do I need to run a node.js web server to deliver page content?

  3. If its a good idea - why won’t the following app.js code return a valid ‘app’?

    var app = require(‘app’)

    // load ember
    var Ember = require(‘ember’);
    var Resolver = require(‘ember/resolver’)
    var loadInitializers = require(‘ember/load-initializers’)
    var config = requrie(’./config/environment’)

    var BrowserWindow = require(‘browser-window’)
    var EmberApp;

    app.on(‘ready’,function() {

    // initialise ember application
    Ember.MODEL_FACTORY_INJECTIONS = true;
    EmberApp = Ember.Application.extend({
    modulePrefix: config.modulePrefix,
    Resolver: Resolver
    });

    // set up main window and load URL
    var mainWindow = new BrowserWindow({
    width: 800,
    height: 600
    });

    loadInitializers(EmberApp, config.modulePrefix);
    mainWindow.loadUrl("./app/index.html");
    })

Any feedback really appreciated.


#2

I’m not really an Ember expert, but I can hopefully help you out with the first two questions:

  1. That’s really down to personal preference. I personally think the single-page application is the way to go, especially if you want your project to ‘feel’ like a program and not a website, so yes.
  2. Electron is self-contained. I’m not an expert on node, but I can assure you that Electron runs entirely from it’s own package.