-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
findAll
reloading is not respected and the model hook resolves before all data is fetched
#242
Comments
findAll
reloading is not respected and the template renders before all data is fetchedfindAll
reloading is not respected and the model hook resolves before all data is fetched
Thinking on this further, I wonder if
|
Hmm, good point on findAll issue. Generally, I'd avoid findAll and use query instead because it's not a good practice in Firestore to fetch a whole collection cost-wise. It's also the reason why I don't support realtime for it. However, not being able to refetch it because reload is disable is definitely a bug which I can look into. |
Thanks @mikkopaderes 👍🏻 Ultimately (I'm working with a small number of records now), I will also use If you were to use You don't support real-time for As always, thanks for this addon, it's been a charm to work with 🙏🏻 |
Will read to other messages later on and respond to it if any, but just to answer this quickly. It's DEFINITELY supported, I'm not sure why I even said that it wasn't, I just probably zoned out for a bit 😅 |
Amazing 🤩 |
I understand and just as you've said, it grabs from the cache as designed by Firestore as indicated in the footnote here. What I didn't know before was that if you have the To solve this with native Firestore, you'd have to fetch the collection using I will look into it and see that whenever we don't provide |
And if you need something immediately, I believe you can extend the adapter into your own app and change this line into |
My ideal scenario would allow I think this issue addresses the mechanics of doing it 'realtime'. |
I see, I understand now. The solution looks interesting but I will have to think about it and see if there's a better way to implement it. I don't just want to add a new property to In the meantime, I imagine that this could be a workaround for now: @service('-firebase')
firebase;
function model() {
return new Promise((resolve) => {
const db = this.firebase.firestore();
const unsubscribe = onSnapshot(collection(db, 'users'), { includeMetadataChanges: true }, (querySnapshot) => {
if (querySnapshot.metadata.fromCache) {
return;
}
resolve();
});
}).then(() => {
return this.store.findAll('users', {
adapterOptions: {
isRealtime: true,
},
});
}).finally((model) => {
unsubscribe();
});
} What this does is that you setup a listener that makes sure to get the latest from the server and have that as the cache when you do |
Hi, I’m struggling to maintain a route’s loading state while
findAll
resolves.I have a
user
model. When a given user logs in theiruser
is loaded into the Store viafindRecord
. There is an admin page where allusers
are loaded viafindAll
. Right now, when I navigate to that page, I immediately see one user (my own) and after a delay the other users “pop” into the template.Here’s the current implementation:
As instructed by the API docs for Ember Data, I’ve included the
reload
option. I had hoped this would be enough to keep things in a loading state until the promise had resolved. However, in the current implementation of this adapter, reload isn’t being respected. I believe this is because of the use ofonSnapshot
infirestoreDataManager.findAll()
, whereby data is grabbed from the cache. Reverting to the use ofgetDocs
delivers the right result (for my use case).Is my implementation wrong - is there already a way to achieve the desired result? If not, would it be possible for the adapter use of
getDocs
in cases whereoptions.reload
is true?The text was updated successfully, but these errors were encountered: