0

I'm loading data from XboxLive and other services in my ApplicationRoute and want to display that information using named outlets. I used this StackOverflow answer as a guide, but it's not working.

Fiddle is here: http://jsfiddle.net/sandalsoft/7xHfp/

In the ApplicationRoute, the model hook loads data from online services. This data is accessible as model.xbox, model.facebook, etc... setupController then sets the content of the XboxprofileController to model.xbox.

This doesn't work when I call App.Xboxprofile.find() (returns a promise), but it does work when I call App.Xboxprofile.findSimple() (returns a simple object). Why doesn't this work when find() has any kind of asynchrony? Am I missing something simple, or is this not the right way to architect this?

thanks

Community
  • 1
  • 1
Eric
  • 323
  • 1
  • 6
  • 17

1 Answers1

0

Thanks to @alexspeller in #emberjs for the answer.

I mistakenly thought model.xbox was a promise. It's an object. When I changed my model hook to use RSVP.hash() it worked perfectly:

model: function(controller)
        var allModels = Em.RSVP.hash({
            xbox: App.Xboxprofile.find('major nelson'),

        }).then(function(hash) {
            return Em.RSVP.hash(hash);
        });

        return allModels;
    },
Marcio Junior
  • 18,813
  • 4
  • 41
  • 47
Eric
  • 323
  • 1
  • 6
  • 17