jeudi 26 juillet 2018

How to return data based on promise

I have a "virtual attribute" in a model, and I want the setter to wait for the promise before returning the value :

idShop:Ember.computed('shop',function(){
    get(key){
      return this.get('shop').id;
    },
    set(k,v){
      this.get('store').findRecord('shop',key)
      .then(shop =>{ 
        this.set('shop', shop)
      })
    }
  })

In the set, I need to return either k(key) or shop.id after findRecord and it's then are solved. How can I do that?




Aucun commentaire:

Enregistrer un commentaire