Currently, a dynamic list of users is being populated with data from the firebase database. However, when any value is updated for a user, it does not immediately reflect on the client side because there is no listener set up for this.
//Loop through All Users
var anotherUserId = snapshot.key;
var ref = firebase.database().ref("users/"+anotherUserID);
ref.on('value', function(snapshot) {
var obj = snapshot.val();
li += ' <div class="contacts-container '+obj.status+'">';
li += ' <h3>'+obj.fname+' '+obj.lname+'</h3>';
});
//End of Loop
If the status is changed for a user, the update will not be visible on the client side until the page is refreshed.
My goal is to achieve something similar to what is shown in thishttps://i.sstatic.net/mHl3w.png
Hence, whenever a user's status in the database changes, the corresponding class in the DIV should also change to display an online/offline signal (Grey or Green).
In essence, real-time updates are currently not functioning as intended, but they do work upon refreshing the page.