Reputation: 1625
Suppose that company
is a promise defined somewhere in the route. In my controller I defined a computed property breadcrumb
based on this promise:
breadcrumb: function() {
return [
...
{name: this.get("company").get("name"), url: "#company/" + this.get("company").get("id")},
...
]
}.property("company")
In my template the breadcrumb never update even after the promise resolves.
{{format-breadcrumb breadcrumb}}
I tried also with observes
but the result is the same. The only way to obtain the result I want is to observe an attribute of company
...
}.property("company.id")
Is this the only way to create a property based on promises? I would like to observe the promise itself, not one specific attribute...
I'm using ember 1.7 and ember-data beta 10.
Thanks
Upvotes: 1
Views: 124
Reputation: 2758
My advice would be to always depend on the properties you care about:
}.property('company.id', 'company.name')
since those are the things that can affect the breadcrumb. If the promise loads and those properties change later, do you want the breadcrumb to be stale (pun unavoidable)
An alternative would be to (additionally) observe the promise lifecycle attributes:
So:
}.property('company.isFulfilled')
See http://emberjs.com/api/classes/Ember.PromiseProxyMixin.html
Additional thought, (I) prefer:
this.get('company.name')
over:
this.get('company').get('name')
Upvotes: 1