-
Notifications
You must be signed in to change notification settings - Fork 2.2k
AngularFirestore.firestore.enablePersistence makes snapshotChanges trigger twice #2808
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
Comments
Please take a look at my comment at #2336 (comment) |
Hi @KingDarBoja and @jamesdaniels I didn't see the issue you linked, but thanks for the reply. I still have some questions though. Can you elaborate on why this is intended behaviour? I find it strange that the I also see that you comented on the linked ticket on august 2020. In version 6.0.3 wich is released in September 2020, the behaviour was as I described. Was this a bug or feature that was not yet fixed/implemented? |
Not part of Firebase team but based on what I have observed and read (not 100% accurate), when you start listening to collection changes with However, I have observed this behaviour even without setting |
Yeah, I kind of understand where that is comming from. But than I think it would always trigger twice. But the "strange" part is, when you get a document for the very first time (it was never retrieved on the device you are calling the subscribe) it only triggers once, because it is not in the cache yet. Thanks for looking into it. |
There was a bug in older versions of 6.x where collections didn't always emit on source change. This may be why you didn't see "duplicate" emissions before. Ultimately with |
If |
|
|
Sorry but if I understand correctly, |
Version info
Angular: 10.0.3
Firebase: 8.2.10
AngularFire: 6.1.4
@ionic/angular: 5.2.3
Ionic CLI: 6.12.1
Node: 12.18.4
How to reproduce these conditions
Steps to set up and reproduce
npm i
ionic serve -l
from the terminalSample data and security rules
Debug output
Two times the
console.log('in snapshotChanges()');
Expected behavior
When calling
.snapshotChanges()
it should only resolve once initially and only a second time after the document is changed.Actual behavior
.snapshotChanges()
is called/triggerd twice. Once for the local cache, the second time because you're online. This was not the case in older versions (6.0.3) of angular fire.The text was updated successfully, but these errors were encountered: