【发布时间】:2019-10-01 15:40:42
【问题描述】:
我想知道是否有任何方法可以在回调本身内停止回调。我尝试使用 ref.off() 方法来停止它,如下所示,但它仍会继续运行。有什么建议吗?
ref.orderByChild('t').startAt(time.getTime()).on('child_added', function (snapshot) {
const d = snapshot.val();
const x = Math.round(d.x * 100).toString();
const y = Math.round(d.y * 100).toString();
if (that.selectedEnd && d.t > that.selectedEnd.getTime()) {
snapshot.ref.off('child_added');
console.log('STOP');
} else {
....
}
});
【问题讨论】:
标签: typescript firebase firebase-realtime-database