Why DS.PromiseObject in component instead of fully loaded model?


#1

So I have the problem, that I load a RSVP.hash as the route model and pass it to a component which passes related models to child components (via computed properties). In the child components, I don’t get the models but the DS.PromiseObject… I don’t get why that is or what I should do different?

Does somebody know what I’m talking about or should I provide some code snippets for better understanding?


#2

I hear you, I have the same frustrations - very annoying. No ideas how to fix, +1 for me too.


#3

Ember don’t render before all Promise models been resolved.

Could you share your route ? I always use modele in that way and never have some trouble.

// someroute.js
model() {
        return RSVP.hash({
             user: UserPromise,
             profile: ProfilePromise,
         });
}

//someroute.hbs
{{ model.user.name }}

#4

This is exactly how I do it - only difference is, I request also included relations and need to display computed properties based on the models… I can share some code tomorrow when I’m back in the office…


#5

Try

// someroute.js
model() {
        return PromiseObject.create({
                promise: RSVP.hash({
                        user: UserPromise,
                        profile: ProfilePromise,
                })
        });   
}

#6

Route? This has nothing to do with a route, I’m afraid. I’m talking about things like in the model itself, for example, an observer in the model. Say I have an observer that is triggered, and I want to get('something') in the model, and something is defined as belongsTo('somethingElse)` - that’s the situation we’re in. Nothing to do with a route or a model. We’re talking about situations where we want to get() a value then use the value.