Angularfire: Noob Question. object.valueChanges vs object.snapshotChanges

Created on 11 Jun 2019  路  5Comments  路  Source: angular/angularfire

Hi. Sorry about this question but.

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

Thanks

Most helpful comment

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' });

All 5 comments

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

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' });

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

@chrisjaimes it was implemented with this PR https://github.com/angular/angularfire2/pull/1976 :)

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jnupeter picture jnupeter  路  3Comments

martinyoussef picture martinyoussef  路  3Comments

Sun3 picture Sun3  路  3Comments

goekaypamuk picture goekaypamuk  路  3Comments

Leanvitale picture Leanvitale  路  3Comments