tonitone120
tonitone120

Reputation: 2310

Why does Firebase's Realtime Database's child_removed event handler not execute?

My database contains:

user: {
  'monkey': 'banana',
  'bear': 'fish'
}

Why does the event handler not execute?

let db = firebase.database();

let user = db.ref('user');

user.on('child_removed', (e) => {
  console.log(e.val());
});

user.child('monkey').remove();  

Upvotes: 1

Views: 154

Answers (1)

WilsonPena
WilsonPena

Reputation: 1571

This looks like some race going on with the code, because I tested and if you do something like this:

 setTimeout(function() {
    user.child('monkey').remove();
  },2000);

it seems to work. Here is a fiddle I used to test it out, hope it helps:

http://jsfiddle.net/bgthp4wc/

Upvotes: 1

Related Questions