小编Man*_*iya的帖子

当与addListenerForSingleValueEvent()一起使用时,Firebase返回旧的数据集

我有一次查询,不想保留一个监听器,以便在发送手动触发器时更新数据.

所以我的查询是这样的:

var ref = this.instance.child('/user/manish/today/events')
    .orderByChild('endDateTime')
    .endAt(endEventTime)
    .limitToLast(10)
    .addListenerForSingleValueEvent(this.previousEventListeners);


  this.previousEventListeners = new com.google.firebase.database.ValueEventListener({
      onDataChange: (snapshot) => {
        console.log("Value from native firebase access");
        console.dump(this.testing(snapshot.getValue()));
        let result = {
          value : this.testing(snapshot.getValue()),
          type : "ValueChanged"
        };
        console.dump(result);
      },
      onCancelled: (databaseError) => {
        console.log(databaseError.getMessage());
        hideActivtiyIndicator();
      }
  });
Run Code Online (Sandbox Code Playgroud)

即使添加了与查询条件匹配的新记录,它也会返回相同的数据集.

谢谢

android firebase nativescript firebase-realtime-database angular2-nativescript

3
推荐指数
1
解决办法
1048
查看次数