I am using firebase to synch data in a real time app. After some treatment, I want to unlink all listeners added. So I put
myRef.off();
But
Let's try it.
ref.on("value", function(snapshot) {
console.log("parent: "+JSON.stringify(snapshot.val()));
});
ref.child("child").on("value", function(snapshot) {
console.log("child: "+JSON.stringify(snapshot.val()));
});
ref.set('1');
ref.child('child').set('2');
ref.off();
ref.child('child').set('3');
ref.child('child').off();
ref.set('4');
The output:
parent: "1"
child: "2"
parent: {"child":"2"}
child: "3"
So after calling off on the parent listener, the child listener still fires ("3"). But if we get the same child and call off, it doesn't for anymore ("4").
JSBin: http://jsbin.com/wutaza/edit?js,console
Conclusion: off() doesn't remove listeners from child nodes.