Using firebase for a small messaging app. Using .on("child_added") functions which also work fine.
The issue is when the app is run, this function fires for all previous children and then stops.
Why does this behavior occur and how can we stop it?
Using firebase for a small messaging app. Using .on("child_added") functions which also work fine.
The issue is when the app is run, this function fires for all previous children and then stops.
Why does this behavior occur and how can we stop it?
Needed to use child_updated instead of child_added
Use a flag.
The first time set a field in your object example:
let read_ts = (new Date()).getTime();
my_ref.on("child_added", snap => {
if ( !snap.val().read_ts ){
console.log("is new")
} else {
console.log("is old")
}
});