deferReadiness for ember-cli


In a globals-based Ember application, you can usually do:

var App = Ember.Application.createWithMixins({...});

But now with ember-cli you can not create the application: instead you have to extend and export:

var App = Ember.Application.extend({...});

export default App;

Since the application is not created, I can not deferReadiness here. How can this pattern be implemented for ember-cli based applications?




My recommendation would be to use an Initializer:

/* global jQuery */
var Initializer = {

  name: 'initializeAsynchronously',

  initialize: function(container, app) {
    jQuery.get('', function(data) {
      // Do stuff with data.
    }).always(function() {


export default Initializer;


Makes sense, thanks!


I can’t find the reference at the moment but someone from the core team told me you should never use deferReadiness in intializers. A better place for this sort of logic is in the model or setupController hooks in your application controller.


One problem with deferReadiness is that it prevents the router from displaying a ‘loading’ state. The router does not proceed until the app has finished initialization. Potentially long-running XHR is not a good use case for an initializer and I would agree that the Route.model() hook is a better fit for this.


@opsb Could you give an example, how to use deferReadiness in model & setupController in Ember CLI?


in your routes/application.js you could do something lik the following:

export default Em.Route.extend({
    model: function () {
        return yourPreviousDeferReadinessLogic();

This will stop the setupController execution until the yourPreviousDeferReadinessLogic promise resolves. If you previously had any other code inside the model hook you could do something like return yourPreviousDeferReadinessLogic().then(...)