Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

When does record relationship getting return promises?

$
0
0

@Alexandr_Rypun wrote:

Say there is a parent model:

// models/order.js    
export default Model.extend({
    ...
    products: DS.hasMany('order-product')
});

and a child model:

// models/order-product.js 
export default Model.extend({
    ...
    order: DS.belongsTo('order')
});

Ember documentation says relationships are async by default. So, I can get products next way

order.get('products').then(products => ...);

But I’ve loaded all data in the route while getting an order. So, if I’m trying to get products synchronously (like const products = order.get('products');) everything works fine. I suppose ember resolves array immediately if records have been loaded into the store.

Am I right? Where can I find official explanations about that?

Thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles