[英]child added and child changed firing multiple times
我正在使用離子和Firebase作為其后端的應用程序。 我正在使用添加的孩子和更改的孩子來觀看兩個單獨的事件,但是對於添加的孩子,它會繼續觸發2次,更改的孩子大約會觸發8次,並檢查火力,我只添加了一個孩子,而不是兩個。這是代碼片段
1。
new Firebase("https://popping-torch-3029.firebaseio.com/btr/users/acceptedBySender/myid/").on("child_added",function(data,prevchild){
console.log('added just fired');
//the console will log this 2 times
});
2。
new Firebase("https://popping-torch-3029.firebaseio.com/btr/users/posted/myid/").on("child_changed",function(data){
console.log('changed just fired');
//the console will log this 8 times
});
我現在已經解決了這個問題。 事實證明,由於控制器已綁定到多個視圖,因此正在重新加載控制器。 每次加載時,都會創建一個新的“觀察程序”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.