Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

valueChanges() to only return affected items of a list change

Working on an Angular5 app using angularfire2. I have a List with a big number of items. When I subscribe to it using:

this.db.list("/list").valueChanges().subscribe(data => { .. });

I get all children of the list in data as expected. When I now change one single item in the Firebase backend, the callback then receives the entire list of all children again.

How can I subscribe to only receive the affected items of a list in data?

Or is it irrelevant because angularfire2 handels the state of the list internally and only transfers the affected items from the server to the app? My target is to minimize connection traffic.

Thanks in advance :)

like image 518
Fabian Avatar asked Jan 25 '18 13:01

Fabian


1 Answers

AngularFire2 valueChanges() always gives you the entire list. If you want just the state changes, use stateChanges.

There are use-case for any of the observable types in AngularFire. Check the documentation to see which one matches your use-case best.

like image 138
Frank van Puffelen Avatar answered Oct 17 '22 21:10

Frank van Puffelen