Firebase database 'child_changed' triggers on push

时间:2017-08-04 12:32:54

标签: javascript firebase firebase-realtime-database

In my web project a locationRef has listener 'child_changed'. This listener triggers every time when I push to this location. I tried to do empty push and set value after and tried to push value - same result, 'child_changed' triggered. From docs it should be triggered only on child changed. As I understand, push(value) implementation is just a combination of push and set. Is there a way to push without child_changed trigger?

chatMessagesRef = firebase.database().ref("chats/chat_messages");
currentChatMessagesRef = this.chatMessagesRef.child(chatId);
currentChatMessagesRef.limitToLast(20).on('child_added', callbackOnNewMessage);
currentChatMessagesRef.on('child_changed', callbackOnMessageChanged);

There are 2 ways I change this location:

currentChatMessagesRef.child(snapshot.key).update({ 'delivered': true });

I've checked that this line is not executed. and

var message = { text: text,
            author: author,
            timestamp: firebase.database.ServerValue.TIMESTAMP,
            delivered: false
        };
this.currentChatMessagesRef.push(message);

0 个答案:

没有答案