ember run loop screws computed property assertions up or is it

In the route, I wait for a promise and set the controller property. I do this in renderTemplate hook method.

File: play_route.js

App.PlayRoute = Ember.Route.extend({
    renderTemplate: function() {
        var ctrl = this.controllerFor('play.index');

        return new Ember.RSVP.Promise(function(resolve) {
            ctrl.set('game', {});
            resolve();
        });
    }
});

In the controller I have a computed property isLoading that checks the game property if it's null, so if the promise (fromrenderTemplate) is resolved isLoading should be true.

Also I have an action that accesses the game property.

File: play_controller.js

App.PlayController = Ember.ObjectController.extend({
    game: null,

    isLoading: function() {
        return this.get('game') === null;
    }.property('game'),

    actions: {
        startGame: function() {
            this.get('game').access();
        }
    }
});

game property is null in the beggining so the startGame action would throw, but if isLoading is false then it is safe to call startGame.

Finally the template makes sure the startGame action is hidden until the isLoading property is false.

File: play_template.hbs

<div {{bind-attr class="isLoading:hidden"}}>
    <div {{action 'startGame'}}>
    </div>
</div>

This works fine, but when the page loads, if i click startGame divin the first couple of seconds of its appearance, it throws game is null error. (as if isLoading property is not respected).

So the question is: is it theoretically possible that following assumptions doesn't hold. Maybe because of emberjs run loop awkwardness or something.

  1. game property is null.
  2. isLoading computed property is true.
  3. game property is set to Object.
  4. isLoading computed property is false.

My problem is the 4th step, which is when isLoading is false only then i can click the startGame action, but it still throws game is null error.

The renderTemplate hook doesn't make any promise to wait on a promise returned to it. In fact it doesn't even care about anything returned from it. Possibly you don't care about that either.

If you have a promise that you need to block the transition, you'll need to return it to either beforeModel, model, or afterModel.

Additionally it looks like you're using the play controller/route etc, but you are trying to fetch the play.index controller and modifying it. So I'd guess game would stay null inside your play controller forever.