0

From the Firebase documentation:

The child_added event is typically used when retrieving a list of items from the database. Unlike value which returns the entire contents of the location, child_added is triggered once for each existing child and then again every time a new child is added to the specified path. The event callback is passed a snapshot containing the new child's data. For ordering purposes, it is also passed a second argument containing the key of the previous child.

I'm currently using the following code to watch for changes:

ref.on("child_added", function(snapshot) {
    console.log(snapshot.val());
}, function(errorObject) {
    console.log("The read failed: " + errorObject);
});

However, the first time I call ref.on("child_added", ...) I see all current children at this path, as specified by the docs

child_added is triggered once for each existing child and then again every time a new child is added to the specified path

Is there a way to just listen for new adds?

Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
Apollo
  • 8,384
  • 30
  • 97
  • 186

0 Answers0