When I thought I finally grasped the concept of how promises work in Ember. This scenario put me back on the train of confusion.
User model has the following association:
profile: DS.belongsTo('polymorphable', { polymorphic: true, async: true })
The route has:
model: function(params) {
return this.store.findRecord('user', 1);
}
In the template, I am rendering a component:
{{model.profile.firstName}}
{{foo-bar saveProfile=(action "save") profile=model.profile}}
{{model.profile.firstName}}
renders fine.
The component template has:
<button {{action "saveProfile" profile}}>Save</button>
The component object has:
actions: {
saveProfile(profile) {
console.log(profile);
}
}
When the button in the component template is clicked. console.log
renders:
Class {isFulfilled: true, __nextSuper: undefined, __ember_meta__: Object, __ember1442167214792: "ember688"}
The template already resolved model.profile
and it is passing the resolved value to the template. Why is profile
(in the component) returning a promise?