-
-
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
Ember store.findAll not getting receiving records in afterModel hook #3657
Comments
If you use this.store.query('model-a', {}); it works as expected. I really think this is a bug. |
I think this is due to the difference in the promises that |
I was pulling my hair out for hours with this a couple days ago. Thought I had just done something wrong. Ended up with a workaround. I feel like this should be documented better at the very least. |
Agreed it definitely should be documented better. I had to dig through the source code of |
Shouldn't all the query methods in ember behave the same? So what's the difference if i query for a record or if somebody uses findAll? Is there a reason why findAll immediatly resolves the promise? |
I definitely agree that it leads to confusion and needs to be documented much better, but it is vaguely in the documentation as such. findAll return a promise that immediately resolves to a DS.AdapterPopulatedRecordArray with a flag that it is currently loading data. query returns a promise that gets resolved with a DS.RecordArray once the server returns the data. |
Ran into this yesterday. Shouldn't |
Ran into this as well. Is there any reason at all for |
In terms of caching the behaviour of findAll and find makes lot's of sense. So according to the ember-data 1.13 release the findAll and find methods are doing the following thing:
So under the hood those methods are doing the following:
The reason why query works is, that it doesn't ask the store before fetching data. That's why it resolves the promise with the fetched data from the server. I think it would be better if the first findAll waits for the server to respond, so that the workflow is as following:
|
This just bit me yet again. Part of me likes the behavior the way it is intended but it just isn't clear what is going to happen from the function name/documentation. EDIT: after reading the 1.13 blog post more carefully I actually find the current behavior ok and actually nice, but it definitely needs to be documented much better in the DS.Store docs. |
This has bitten me too, been struggling with it for days now. Aside from the documentation needing work, the biggest problem I have with it is that I haven't yet found a way to make good use of it in code (Ember itself copes just fine). How this now should work is actually much like Firebase does things already with its native API, though there it's well documented how you can first get an "initial set of data" and then "listen for updates". In my application route I'm preloading several models from Firebase; then in a "display a map" component I need to work with these records and draw them into a WebGL canvas. So far though, both my application route and component are initialized well before the data is actually loaded and I'm struggling to find a way to attach a promise that responds as data is still coming in. I'll have to try some of the suggestions above. |
In my opinion it is very very important that one method always has the same behaviour, so doing the first time something different then other times is weird as suggested by @webpapaya. However, a user opts in for different behaviour when he chooses to reload in the background. So @webpapaya does have a point here. Moreover the signatures of the So I think the suggestions by @webpapaya should be taken into account. |
Oh, I think this bug and #3483 are duplicates. |
@webpapaya the I am going to close this issue, since the documentation for the reload and background reload behavior should have improved now that #4338 has been merged. Feel free to reopen / comment here if you think this still is not documented sufficiently. Thanks! |
Hey,
I'm using ember-data 1.13.7 and I have the following Route which loads data from the server. And I need to do some computation on multiple models which are not related to each other. I have the following code.
When I'm using the deprecated find() Method the Models are passed in to the store but when using the new findAll method the models are resolved at a later time.
The text was updated successfully, but these errors were encountered: