Android Couchbase Lite how to know if all the documents is synced?


#1

I have implemented Couchbase Lite and now I want to implement logout feature in my app. I have a documents that have a state field and there could be one of these values: LOCAL, UPLOADING, UPLOADED, INVALID. when user press the logout button I need to upload all the files that are attached to couchbase documents (simply look for id and if id is the same upload file and if upload is successful change couchbase state field and then immediately logout (clear database and replications). Problem is that sometimes state field is not updated. How to know if all files are synced to server in android?


#2

Please specify the version of Couchbase Lite .

Unless I am missing something, it seems redundant to have a state associated with the documents to track what is effectively the progress of the sync. That’s what the replicator status is supposed to provide you and the replication protocol takes care of determining changes that need to be synced

Take a look at the addChangeListener method to register listener to notify app of changes to replication status.

You can also use the getPendingDocumentIDs to track local changes that have not yet been pushed.

Then you can monitor the status and handle log out accordingly.

Note that if you are running replication in continuous mode, it will automatically take care of uploading documents as and when they change locally .


#3

Hi, I’m really interested in this feature, but I’m unable to find the equivalent method in Couchbase Lite 2.1 docs… Does 2.x version of Couchbase Lite support this feature?