I'm making an app similar to Google Keep. When you input some data, it gets uploaded to a firebase database, ready to be loaded later. Problem is, when you have two clients online at the same time from two separate devices, when you update the data from device A (e.g. 123 -> 12345), on device B it still has that old data (123) and will upload that old data to the server, discarding all the changes I made on device A.
One way of solving this would be constantly loading data from the server on all clients, but I don't think that would be efficient since it could cause some serious lag to the client or the server.
So what I thought of is this. Whenever the data gets updated, the client or server somehow sends some kind of signal to the other client, making it load and update the data from there.
My question is: What's the best way to do it?