What is the latest with initialization and deferReadiness()?


#1

If someone in the know could please describe the current and future states of support for “deferring readiness”, or what I would like to call “hold-off-the-router-until-the-things-it-needs-for-the-requested-route-are-ready” support, I would be grateful.

Here is one example of what seems to be a myriad of issues that look like a tug of war between people who want support for lazy loading and those who’d rather not focus on it (perhaps for now, perhaps never).

(Please count me as someone who wants it, if that makes a difference.)

But most importantly – does anyone know how it is supposed to work today and how it will work in the near future? I can’t follow all of the closed and reopened issues. From the looks of it, it seems like a pow-wow would have been or would be useful. Or maybe everything’s settled, in which case could someone explain the latest?

I’m hoping that the end result is that deferReadiness will work after app init to hold ember off while lazy loading things that are needed for a route. But knowing how it does work and how it probably will work for v1 would be a great leap forward for me and I’m lost in the github issues weeds.

Just FYI – I’m interested because I’d like to have lots and lots of dynamic templates coming from the server. I’m ok with loading all the other stuff up front (though I am using RequreJS and so in development I’m really struggling to hold Ember back from launching into things).


#2

BTW, what does this mean, from the docs: “However, if the setup requires a loading UI, it might be better to use the router for this purpose.”?

As far as I can tell, deferReadiness isn’t working for me. In fact, even though I have logging code all over my app, the very first thing I see in the log is "Transitioned into ‘index’ ". This is my relevant code:

  App = Ember.Application.create({
    LOG_TRANSITIONS: true
    , rootElement: "body"
  });
  App.deferReadiness();

What concerns me is that it is also, seemingly, only supposed to work prior to initialization of the app. What if I want to hold off routing later in the day? For instance, if I’m loading a template for a view. Is there a place for that?

    @method deferReadiness
  */
  deferReadiness: function() {
    Ember.assert("You cannot defer readiness since the `ready()` hook has already been called.", this._readinessDeferrals > 0);
    this._readinessDeferrals++;
  },

  /**
    @method advanceReadiness
    @see {Ember.Application#deferReadiness}
  */
  advanceReadiness: function() {
    this._readinessDeferrals--;

    if (this._readinessDeferrals === 0) {
      Ember.run.once(this, this.didBecomeReady);
    }
  },

?


#3

Update: the “transitioned into” log message seems errouneous (or maybe just misleading)… because it shows up again when all of my readiness deferrals are wiped out, so it does seem that readiness is being deferred. Please disregard the “it doesn’t seem to be working” message…

However, the question of how to defer loading templates still remains. I haven’t figured out how to do that.