Open euwars opened 8 years ago
We currently don't expose any notification functionality on whether the client is connected to the server. I am assuming this is what you would need so that you can prevent the user from doing any writes unless the client is connected?
More generally, you don't need to do this from a sync perspective with Realm Mobile Platform. We are designed to be offline-first, meaning that the client can always apply changes to the local Realm database running on the device and that these changes will always succeed in synchronizing at a later point in time. We are able to do this by automatically handling conflicts, see here for more details.
@bigfish24 Yes that is correct, let's say i have a live chat like something on twitch.tv if user post is not going to be added right away, it doesn't really matter if it's gonna be added later at some point it loses the value of "live chat".
I understand that RMP is offline-first, but this causes some issues. for example on app launch i check if realm database is empty so i can add some starting objects. if the first time launch user is not connected to server, it will add the objects, even if server database is not empty. later on when it syncs i get multiple same objects.
Having the ability to monitor connection between server and client will give the power to control change of database.
@euwars we are working on exposing notification functionality that will let you know about the status of data sync. I would expect this to land in the next couple weeks.
@euwars Just to be perfectly clear, I don't think it's wise to rely on connectivity to try to ensure the consistency of your data model. Even if you only let the user make changes when the device is online, connectivity can easily be lost between committing the update and uploading it to the server. This may be good enough as a usability hint, but not to prevent duplicate global objects. We recommend using Primary Keys in that situation. Objects with the same primary key will be considered the same object regardless of the device they originated on.
Realm relies on convergence and eventual consistency rather than full consistency, because full consistency would imply distributed locks, which would be quite difficult to work with given the spurious connectivity of mobile devices. :-)
Hi there,
As far as i can understand mobile platform sync the local database with remote server whenever it can. This is great for apps that need to be functional even when there is no internet connection. but right now i'm working on a project that everything has to be live and when user has no connection i want to not let user change anything from local database.
is there a sync failure notification or such thing OR is there a chained write method that syncs right after and gives result of both at the same time?