-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to tell if the result of a findAll had any records from the adapter #83
Comments
Rationale is I want to be able to determine whether there are genuinely no instances of a model on the server vs just there not being any instances on the client yet. |
Just to be clear on semantics, what you're saying is that as soon as a single item for a type was added to the store, all |
@wycats I'm okay with that, but the problem then is what happens if the server has no instances of that type? My goal is to display a UI that says "There are no Cars", but I don't want to show this UI while any potential Cars are loading from the initial call to |
My 2 cents... I also need some notification mecanism to perform some processing once the findAll has complete results loading. I may be wrong, but it seems to me this observation is quite "transient", and it is certainly useless to keep this observation after it has been triggered once. @pixelcort Do my need meets yours? @wycats Would it be ember-idiomatic to have such a callback mecanism? |
Just found a solution to my problem, which could also match your need, @pixelcort : http://stackoverflow.com/a/9568939/90741 |
@MikeAndrzejewski that works but feels like Store#findQuery is a private method and that we should instead be using Store#find. Your workaround would probably also work with Store#filter with a function that always returns true, and that would guard against implementation detail changes inside of how findQuery works. However, in any case, this doesn't resolve the issue, which is how do I determine whether the adapter returned no items for a given findAll query, or simply that it hasn't returned yet. |
Updated title to better reflect issue. |
Triggering a event once the |
+1 this is pretty annoying... |
Here's how I worked around this issue. I created a new findAll(store, type) {
var request = { ... }
var success = function(data, status, xhr) {
data = JSON.parse(data);
store.loadMany(type, data);
store.typeMapFor(type).findAllCache.set('isLoaded', true);
}
$.ajax({
'url': 'data.php',
'type': 'POST',
'data': {request: JSON.stringify(request)},
'success': [success],
'async': async
});
} Seems to be working for me. I can now observe |
@mmpestorich nice workaround; I'll try using that next time. Thanks! |
I just posted Pull Request #271 that implements |
Looks like f707b6c addresses this. |
It does. Thanks. |
Currently
DS.Store#findAll
returns an instance ofDS.ModelArray
, which does not include anisLoaded
property.Instead,
DS.Store#findAll
should return something that includes anisLoaded
property.When the adapter returns all the data for the
findAll
, theisLoaded
property on the originally returned result ofDS.Store#findAll
should change totrue
.The text was updated successfully, but these errors were encountered: