I have an Ember method which fires when when new data arrives:
insertDays: function() {
...
}.observes('startDate', 'doctor.appointments.length')
I want to check to make sure the data is actually there before I execute any heavy code. To do this I currently use:
var length = doctor.get('appointments.length')
if (length !== 0) {
...
}
However, there are occasionally times where there is legitimately no data being handed down from the server, and in this case my !== 0 test fails, and the code doesn’t execute when I want it to.
I’ve tried using the .isLoaded method but it always returns true regardless.
How do I effectively tell if an Ember resource is still loading?
I got this working by using
.isLoadedas an.observesproperty.The code is now structured as follows and works as expected:
Elsewhere in the program I was able to use the following code to ascertain whether the data had loaded:
Thanks to @Unspecified for steering me in the right direction. Cheers!