Ember App Kit: How to deal with (utility) classes/objects


hey there,

I really tried to use StackOverflow for my questions/problems related to Ember App Kit but it seems that either nobody who uses or knows Ember App Kit is present over there, or the people are not interested in giving answers/advices to those who need it :wink:

so, now I try my luck here - hope to get some feedback here :smile:

Until now, I used to develop my Ember project with the boilerplate which was given by @trek (https://github.com/trek/ember-todos-with-build-tools-tests-and-other-modern-conveniences) but now I want to migrate it into Ember App Kit. so far so good. I’ve got some util classes / objects which are now living within the App namespace so that they’re accessible from all my other objects/controllers/routes/models/views/ etc.

window.App = Ember.Application.create({

  Resolver: Ember.DefaultResolver.extend({
    resolveTemplate: function (parsedName) {
      // some fancy stuff to get my templates from the server on demand...
  ready: function () {

App.creationTime = Date.now();


App.AjaxManager = App.utils.ajax.AjaxManager.create({creationTime: App.creationTime});
App.localStorageTimeout = 24 * 60 * 60000;
App.EventDispatcher = App.utils.event.EventDispatcher;
App.StorageLogger = App.utils.logging.StorageLogger.create({storageManager: App.utils.browser.storage.StorageManager.create({'prefix': 'app'})});

// ... some more util classes


so, this is my code base now, but if I want to transfer this to EAK I see troubles all the way and I have a few questions:

  • how would I implement my application wide util classes/objects?
  • is it still possible to have some properties within the App namespace so that this is available within controllers/routes/models/views etc. as before?
  • do I need to transfer the code into Ember.Application.initializer?


EAK uses ea6 modules, so you have to do this.

import Util from 'app/utils/myUtil'

and if you want to bring it to a route, for example:

import Util from 'app/utils/myUtil';
export default Route.extend(Util, {});

Its still possible to have them in the app namespace, but that’s not the best way to do it.

For an example on exporting your uti , check https://github.com/stefanpenner/ember-app-kit/blob/master/app/utils/ajax.js

I’ll head to SO and answer there.


thanks a lot for your answer - I forgot to mention that I’m already familiar with the es6 modules and how to write/import them… my question may be a bit too unspecific, so I’ll try to explain myself in another way…

to create my util classes I need some shared values which I would place in the App namespace (or even in a self written container object or something alike) and - until now - the util classes are all instantiated right after I instantiated my App with Ember.Application.create({}). the problem is, that if I create all my utils in Ember.Application.initializer methods it seems that some other classes/objects which need the utils as dependencies are created in parallel and therefore are either undefined or throwing errors.

is there a way that I could instantiate/use my util classes in a similar way with the EAK? or is it possible to call something like a Config function right after I exported my App with export default App;?