How to observe the addition of a child event in firebase

Is there any way to watch grandchild_added event with firebase?

I set an observer for child_added using the javascript node.js library, but will not start when the child element is added.

I am setting member presence information and would like to know when users enter the room.

i.e.

Members / number / uname

+4
source share
3 answers

Listen to child_changed. Adding a grandson is considered a replacement for the child.

This may not be as detailed as you like, unfortunately, but this is the only thing that worked for me. (Perhaps listening to the “value” also works, but it's even less granular.)

+2
source

child_changed . .

.

javascript, :

var Firebase = require("firebase");
var firebaseParentUrl = config.firebase.url
var firebaseChildUrl = config.firebase.url + "/child"

var parent = new Firebase(firebaseParentUrl, config.firebase.secret);

theParent.on("child_added", function (snapshot) {
    var id = snapshot.key()
    var theChild = new Firebase(firebaseChildUrl + id, config.firebase.secret)
    theChild.on("child_added", function (snapshot) {
        var grandChild = snapshot.val()
        //now do something with grandChild
    })
})
+6

It is already implemented for subchild events in firebase. When you change any key / value of a grandson, its parent child event is fired, but you need to track it by the value of the parent child.

0
source

All Articles