Skip to content
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

Loading state does not work with syncing empty collection #238

Closed
randallmeeker opened this issue Feb 5, 2022 · 10 comments · Fixed by #270
Closed

Loading state does not work with syncing empty collection #238

randallmeeker opened this issue Feb 5, 2022 · 10 comments · Fixed by #270

Comments

@randallmeeker
Copy link
Collaborator

randallmeeker commented Feb 5, 2022

If I'm syncing a collection and it is empty the loading state will not revert to false.

The loading state does not turn false till we process individual documents. HERE

It would seem to me that we could reset the store HERE instead of where the results of the sync'd collection is returned.

Thoughts, or am I very wrong here?

@randallmeeker randallmeeker changed the title Loading state does not work with empty collection Loading state does not work with syncing empty collection Feb 5, 2022
@hakimio
Copy link
Contributor

hakimio commented Feb 6, 2022

Not sure I understand the problem. Do you mean that collectionChanges never emits anything when collection is empty? Are you setting syncOptions.loading config?

@randallmeeker
Copy link
Collaborator Author

I am, but if the returned result of a sync collection is an empty array then loading never goes from TRUE to FALSE. It is set up to only turn the loading state FALSE in syncStoreFromDocAction which only processes individual items in the store. If an empty array is returned, then nothing is processed and the loading state stays TRUE.

@hakimio
Copy link
Contributor

hakimio commented Feb 6, 2022

Can you create a PR with a unit test reproducing the issue?

@randallmeeker
Copy link
Collaborator Author

Sure, will see what I can throw together this week. 👍

@Benny739
Copy link
Contributor

Any news here?

@hakimio
Copy link
Contributor

hakimio commented Feb 28, 2022

@Benny739 feel free to make a PR. Nobody seems to be working on this one.

@randallmeeker
Copy link
Collaborator Author

@Benny739 @hakimio Wanted to get this done the 9 to 5 is more like 9 to 9 these days. I'm happy to help, but won't get back to this for another week or so when I hop back on the project I was doing this for. I never really used the loading states in this until I had a brand new project to do so and noticed them broken. I almost 100% I have a valid fix by must moving the setLoadingState higher up in the call action.

@Benny739
Copy link
Contributor

Benny739 commented Mar 17, 2022

Do you have an idea how to solve this? CollectionChanges doesn't emit anything when there is no data. We switched to CollectionData in our app and then we replace all data in the store every time we get new data, but this is not very beautiful.

There is already an open bug in rxfire: FirebaseExtended/rxfire#55

@randallmeeker
Copy link
Collaborator Author

Yes, my original post shows where a change could be made. I have been a bit underwater as of late, but should be able to work on this next week.

The RxFire bug is interesting as I did not encounter than in this, but In my tests I don't know that I'm syncing with a query. I will say if the RxFire bug is legit, solving this problem here will only solve it for syncing w/o a query. RxFire would still have to be fixed for a full solution.

@luke-rogers
Copy link
Contributor

Opened #270 which should hopefully fix this issue.

@Benny739 be great if you could give it a test in your app and feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants