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

Noob Question. object.valueChanges vs object.snapshotChanges #2106

Closed
Hanzofm opened this issue Jun 11, 2019 · 5 comments
Closed

Noob Question. object.valueChanges vs object.snapshotChanges #2106

Hanzofm opened this issue Jun 11, 2019 · 5 comments

Comments

@Hanzofm
Copy link

Hanzofm commented Jun 11, 2019

Hi. Sorry about this question but.

After read the docs, Someone could explain for dummies the difference between .valueChanges and .snapshotChanges()?

Thanks

@randelllamontgroup
Copy link

You would use .snapshotChanges() whenever you want to get the metadata of a doc (e.g. DocumentID) and .valueChanges() when you need the data within the doc. You can't get document data from .snapshotChanges().

https://stackoverflow.com/questions/48608769/what-is-snapshotchanges-in-firestore

@joeyaurel
Copy link

joeyaurel commented Jun 11, 2019

Plus: The newest version of AngularFire allows you to use valueChanges() in a way that it also maps the ID of the document to the document data that is being returned in addition to the document data itself.

const tasks: Observable<Task[]> = this.firestore.collection<Task>('tasks').valueChanges({ idField: 'id' });

@chrisjaimes
Copy link

thaanks! @nickreynke where in the docs did you see that?

@joeyaurel
Copy link

@chrisjaimes it was implemented with this PR #1976 :)

@newmesiss
Copy link

Usaría .snapshotChanges () siempre que desee obtener los metadatos de un documento (por ejemplo, DocumentID) y .valueChanges () cuando necesite los datos dentro del documento. No puede obtener datos del documento de .snapshotChanges ().

https://stackoverflow.com/questions/48608769/what-is-snapshotchanges-in-firestore

if I use snapshotChanges () is it counted as a call to the document?

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

No branches or pull requests

6 participants