Comments (2)
Hi Zoltan, I tried modifying the adapter's behaviour with shouldBackgroundReloadAll
and shouldReloadAll
but that didn't help. I agree that I could probably solve the problem by adding real time communication via websockets between the ember store and the server but that is probably complete overkill if one does not need it to be realtime.
But it turns out other people are having the same issue: emberjs/data#4564
The findAll()
method ignores items that are missing in the server response but still present in the local cache and it looks like this is not going to change. This is the expected and documented behaviour of findAll()
:
findAll asks the adapter's findAll method to find the records for the given type, and returns a promise which will resolve with all records of this type present in the store, even if the adapter only returns a subset of them.
So in the end I found 2 workarounds for this:
- Clear the local cache of library objects if you're going to load them all
model() {
this.store.unloadAll("library");
return this.store.findAll("library");
}
- Use
query()
which doesn't do this. If you want to load all objects pass an empty hash as the parameter or parameters your server will ignore:
model() {
return this.store.query("library", {});
}
I feel that with these workarounds the issue is acceptable as one might usually use query()
on large datasets instead of findAll()
anyways to have pagination, filtering and such.
Thanks four your quick response and helping me find a workable solution. 👍
from library-app.
@dominiks Hey Dominiks, thank you.
Great findings and you are right. I noticed the same when I started to play with Firebase. As I see Firebase realtime sync your data when you create a new item, however they don't sync "delete", so it is not realtime... As I see here, in Firebase doc, the official Firebase library supports this option, maybe this is missing from the Emberfire package.
If you built your own server backend, you have to manually setup realtime "websocket" communication.
You can check out this hooks also in Ember Adapter:
https://www.emberjs.com/api/ember-data/3.7/classes/DS.Adapter/methods/shouldReloadAll?anchor=shouldBackgroundReloadAll
You can force your Adapter to reload all the records from the server. So it is always try to find out what is the latest state of your database. Maybe this is only what you need.
Hope this could help, don't hesitate to share your findings and let me know which solution worked. :)
from library-app.
Related Issues (20)
- Tutorial is Outdated HOT 4
- Expand the tutorial to cover pagination? HOT 3
- _parent.type is undefined HOT 3
- Migrate bootstrap-sassy to ember-bootstrap HOT 1
- Update EmberFire to v3.0rc
- Migrate the app to Ember Octane
- Not Ember Octane Syntax HOT 2
- Update `action`s to `on` and `fn`
- Fix `author-select` test
- Fix `fader-label` test
- Fix `nav-link-to` test
- Add prettier formatter
- Fix yarn test:coverage task
- Fix all the yarn lint:hbs linting error with upgrading syntax
- Question on Query on has-many Attributes HOT 1
- beforeEach and async pattern in seeder controller HOT 1
- fix computed-property.override deprecation
- Using CP-validations instead of comp props on the model? HOT 1
- What about using closure actions instead of actions? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from library-app.