dimanche 27 septembre 2015

Handling chained Promise in computed property

If I have a then() function on a promise it never resolves properly via a computed property

So this is OK,

  taxRate: computed(function() {
    return this.get('store').findRecord('tax-rate', { current: true });
  })

But this is not, (outputs [object Object] - the promise - in the htmlbars template)

  taxRateValue: computed(function() {
    return this.get('store').findRecord('tax-rate', { current: true }).then((taxRate) => {
      return taxRate.get('taxRateValue');
    })
  })

So what is the correct way to handling this without using an observer?




Aucun commentaire:

Enregistrer un commentaire