在应用程序(例如使用react native的iOS/Android)或网站中,重新启动firebase绑定有问题吗?
以下代码为例:
var starCountRef = firebase.database().ref('posts/' + postId + '/starCount');
starCountRef.on('value', function(snapshot) {
updateStarCount(postElement, snapshot.val());
});
如果我碰巧多次启动绑定函数:
starCountRef.on('value', function(snapshot) {
updateStarCount(postElement, snapshot.val());
});
它会抹掉上一个吗? 或者它堆叠在另一个上面,我从firebase收到更新,以防对象多次更改?
先向社区表示感谢
如果您在一个位置有两个侦听器,则数据在网络流量方面不会重复。 两个侦听器将共享来自数据库的相同传入快照。