I need to wait on a promise in one of my helpers. I’ve tried returning just the promise and it displays [object object]
. When i try to return a PromiseObject it just sets the display value to <DS.PromiseObject:Ember1900>
.
Should i be using components for this instead?
Here’s my helper code.
export default Ember.Helper.extend({
session: Ember.inject.service(),
compute: function(params, hash) {
let unitRecord;
let user = this.get('session.user');
switch (hash.assetCategory.get('id')) {
case "0":
unitRecord = user.get('speedAir');
break;
case "1":
unitRecord = user.get('speedLand');
break;
case "2":
unitRecord = user.get('speedSea');
break;
default:
unitRecord = user.get('speedOther');
}
return DS.PromiseObject.create({
promise: unitRecord.then((record) => {
return (params[0] * record.get('centimeterFactor')) + record.get('shortName');
})
});
},
shoudRecompute: function() {
this.recompute();
}.observes('session.user.speedLand', 'session.user.speedAir', 'session.user.speedSea', 'session.user.speedOther'),