我需要一个倾听者,看看我的表的通知(节点)已经改变了实时数据检查 [英] I need a listener to see if my notifications table (node) has changed for real time data checking
本文介绍了我需要一个倾听者,看看我的表的通知(节点)已经改变了实时数据检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
火力地堡 - 我需要一个倾听者,看看我的表的通知(节点)已经改变了实时数据检查
Firebase - I need a listener to see if my notifications table (node) has changed for real time data checking.
我使用angular2与打字稿和火力点为我的项目。
I'm using angular2 with typescript and firebase for my project.
推荐答案
您可以使用这样的事情:
You could use something like that:
export class AppComponent {
items:Array<string>;
constructor() {
var firebaseURL = "https://something.firebaseio.com/somethingelse";
var myFirebaseRef = new Firebase(firebaseURL);
myFirebaseRef.on('child_added', (childSnapshot, prevChildKey) => {
childSnapshot.forEach((records) => {
this.items = itemsarr.push(records.val());
});
console.log(itemsarr)
});
console.log(itemsarr);
}
}
要小心,以实例化火力地堡
组件内的对象进行Angular2意识到项目
的变化。
Be careful to instantiate the Firebase
object within a component to make Angular2 aware of changes of items
.
希望它可以帮助你,
蒂埃里
Hope it helps you, Thierry
这是我目前的code,但时通报添加到表它不是射击:
waitingForNotificationChanges = (): void => {
this.refNotifications.on('child_added', (childSnapshot, prevChildKey) => {
console.log("Notification table changed");
this.getNumberOfNotificationsByUid();
});
};
这篇关于我需要一个倾听者,看看我的表的通知(节点)已经改变了实时数据检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文