jeudi 25 mai 2017

Ember helper that returns the resolved value of a promise

How can I get this helper to return the result of a promise?

// helpers/city-temperature.js

import Ember from 'ember';

export default Ember.Helper.extend({
  weather: Ember.inject.service(),
  compute(params) {
    let location = params[0];
    let temperaturePromise = this.get('weather').getTemperaturePromise(location);
    return temperaturePromise.then((value)=>{
      return value;
    });
  }
});

I modeled it after code from this discussion. It's retrieving the value from the remote API but I'm not able to get it to display in the component. And I want to do it without passing a DOM element around.

The complete app code is here.




Aucun commentaire:

Enregistrer un commentaire