I have a simple scenario where i have attached listener on dynamic path in Firebase.
a
.. b
..... c (dynamic multiple nodes)
..... c1
......c2
ref.child(a).child(b).child(c).on('child_changed',onChildChange);
I am removing some c nodes as per some conditions, so do i need to listener from it or will it be automatically removed.
答案 0 :(得分:1)
Just the opposite of the .on
:
ref.child(a).child(b).child(c).off('child_changed',onChildChange);
答案 1 :(得分:1)
You have to call remove
on a reference to remove data.
firebase.database().ref('a/b/c').remove();
child events are used to monitor data in the list, you can use these events to know when data has been added, modified or removed.
In your case, you should use child_removed
, note that using this event has nothing to do with data removal. Whenever you work with lists, it is recommended that you use all 3 child events in conjunction.
firebase.database().ref('a/b/c').on('child_removed', function(data) {
//Data has been deleted, do something here!
});