I am using this question as a reference, since it is very similar.
If I have a set of defined keys:
-Ke1uhoT3gpHR_VsehIv
-Ke8qAECkZC9ygGW3dEJ
-Ke8qMU7OEfUnuXSlhhl
and also know that they all do exist under a node (let's say /items
), how would I query for them, while also listening for changes on those keys (aka not using myRef.once(value)
but using myRef.on('value', snapshot => { ... })
I know this is possible:
var keys = [
"-Ke1uhoT3gpHR_VsehIv",
"-Ke8qAECkZC9ygGW3dEJ",
"-Ke8qMU7OEfUnuXSlhhl"
];
var promises = keys.map(function(key) {
return firebase.database().ref("/items/").child(key).once("value");
});
Promise.all(promises).then(function(snapshots) {
snapshots.forEach(function(snapshot) {
console.log(snapshot.key+": "+snapshot.val());
});
});
but it is a static snapshot. Could it be possible to do the same while listening for changes?