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

大城市里の小女人 提交于 2020-11-29 10:34:46

问题


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();  

回答1:


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/



来源:https://stackoverflow.com/questions/64740632/why-does-firebases-realtime-databases-child-removed-event-handler-not-execute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!