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
Delay before disconnecting useFirestore #2252
Comments
I think it's the simplest way
Can you do this? I want to know how it is implemented. |
I will make a PR to have some code to discuss on. But yes you can do that with a watchOnce and call the close method when data is updated. If it's an other listener on the same document it's won't be an issue because it's will just close the old one. |
This is my current implementation using a custom composable; |
Thanks, let's discuss on your PR 👍 |
It's may take a few days, I have some issues to setup a dev env #2268 |
@kiyopikko why did you limit close to query only ? Documents read need to be closed too. vueuse/packages/firebase/useFirestore/index.ts Lines 99 to 103 in 2419803
|
@Zehir oh, that's a mistake and thanks for making PR! I cared about compatibility, I wanted to write
because documents always close regardless but almost users will expect to be able to use
is good like your PR. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Up |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
#2276 is updated |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Clear and concise description of the problem
In the case you are using vue-plugin-pages you can have a case that you load the same documents multiple times in case you came back to a page you already loaded once.
But when you change the page the connection is closed at the moment you left the page thanks to:
So you will be charged by one read each time.
Suggested solution
Using a little delay could alow you to use the cached document instead of get one new.
You don't need more code because the firestore sdk handle it by default. Even if the first
useFirestore
is closed I still get updates on the newuseFirestore
Alternative
An alternative is to store your
useFirestore
in a pinia store but it's lead to many tracks of what you put there.Additional context
I can make a PR for that but I don't know about the delay, should it's be lower ? configurable ?
Maybe a force close option ?
Maybe a close if I get an update during the timeout ?
Validations
The text was updated successfully, but these errors were encountered: