Reputation: 28810
What is the best way to know when an entity has been retrieved from the remote store in ember-data?
I need to make a call to retrieve data but I need some values from a fetched ember-data object.
At the moment I am using this approach but I am sure there is a better way.
contactLoaded: function(){
if(!this.getPath('contact.isLoaded')){
return;
}
//make call
}.observes('App.contact.isLoaded')
Upvotes: 5
Views: 676
Reputation: 3309
You can also do
model.one('didLoad', function() {
alert("I LOADED!";
});
Substitute didLoad with didCreate, didUpdate, etc., depending on the async event you're looking for.
one
will watch the object for the didLoad
event to fire and won't fire more than once. Use on
to keep watching.
Upvotes: 1
Reputation: 9236
I am fearing it is the only way to achieve your goal, as of today... :-/
Upvotes: 3