有关可验证的示例,请参阅jsbin.com/ceyiqi/edit?html,console,output。
我有一个监听数据库点的引用
作业/ <key>
/列表
其中<key>
是球队唯一号码
在此入口点下方是作业
的列表我在这一点上有一个听众
this.jobsRef.orderByChild('archived')
.equalTo(false)
.on('child_added', function(data) {
我还有一个执行以下事务的方法:
ref.transaction(function(post) {
// correct the counter
if(post)
{
// console.log(post);
if(active)
{
// if toggeling on
}
else
{
// if toggeling off
}
}
return post;
})
调用事务时,还会再次调用child_added
,为我提供重复的作业。
这是预期的行为吗? 我应该只是检查项目是否已经获得并相应地添加到数组中? 或者我做错了什么?
提前感谢您的时间