Imagine a scenario where I and my 3 friends are accessing the same website from different computers simultaneously. Each of us has a profile stored in an array like this:
$scope.profilesRanking = [
{name:"Bob", score: 3000},
{name:"John", score: 2500},
{name:"Carl", score: 100}
]
These profiles are sorted based on their scores, and what we want is for any changes to reflect across all users' screens without having to refresh the page. For example, if both Carl and John gain 3000 points each, everyone's scoreboards should update in real time without interrupting other processes.
So, ideally, all 3 users should immediately see:
$scope.profilesRanking = [
{name:"John", score: 5500},
{name:"Carl", score: 3100},
{name:"Bob", score: 3000}
]
We are currently using Firebase to store this data, but we're wondering how we can efficiently check the database values without overwhelming it with requests. Our initial thought is to send a request every second, but we feel like there might be a better approach to achieve this seamless synchronization.