Closed bnfrnz closed 6 years ago
No one?
I still can't get this to work. Even when specifically asking for all events, it doesn't fire.
.valueChanges(['child_added', 'child_removed', 'child_changed', 'child_moved'])
After receiving the first item once, it doesn't fire anymore when the item is then removed or a new first item is inserted.
How can I subscribe to the first item of a list then? Any ideas?
EDIT:
As workaround, .orderByChild('timestamp').limitToFirst(1)
fires as expected. Just .orderByKey().limitToFirst(1)
does not work.
Hey @bnfrnz! You are in the wrong repo. This is AngularFire for AngularJS. Go to the AngularFire for Angular repo for help: https://github.com/angular/angularfire2
Oops, my bad
angular "5.0.0", ionic-angular "^3.9.2", firebase "^4.7.0", angularfire2 "5.0.0-rc.4",
Test case
I'm getting the first key of a list of notifications to determine whether my pagination logic should continue querying or I have reached the first key:
When I subscribe to this, it fires as expected and delivers the first key. But when I then remove the respective item in the database. it does not fire again. When I readd the item, it also doesn't fire again. It basically only fires once. It's like later child removed and child added etc. events are being ignored.
Am I missing something? Is this expected behavior for some reason?
Steps to reproduce
Add a few objects in firebase rtdb. Take the above code, subscribe to the observable, and log the result to the console. Then remove the first object in the list... nothing fires.
Expected behavior
When the list changes, ie. the first object is removed or another one is inserted before it (so, the first object is now a different one), I would expect the observable to fire and give me the new first object key or null in case the list is now empty.
Actual behavior
Subscription does not fire (see above).