我有一次查詢並且不想保留一個偵聽器,以便在發送手動觸發器時數據更新。Firebase在與addListenerForSingleValueEvent()一起使用時返回舊數據集
所以我的查詢是這樣的:
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();
}
});
返回即使追加新的記錄匹配查詢條件相同的數據集。
謝謝
這很可能是您使用磁盤持久性。 Firebase的磁盤持久性和「addListenerForSingleValueEvent()」不能很好地混合。請參閱http://stackoverflow.com/questions/34486417/firebase-offline-capabilities-and-addlistenerforsinglevalueevent/34487195#34487195 –