I am using couchdb as server and couchbase lite 1.4.4 in android app.
Live query and database add change listener not called some times while changes in document.
Below is my code;
val query = database?.createAllDocumentsQuery()
query?.startKey = "refill-device-SERIAL-AB121-0"
query?.endKey = "refill-device-SERIAL-AB121-7"
liveQuery = query?.toLiveQuery()
liveQuery?.addChangeListener { event: LiveQuery.ChangeEvent? ->
try {
arrayList.clear()
val enumeration = query?.run()
if (enumeration != null) {
for (row in enumeration) {
Log.e("CityExplorer", "Row is " + row.documentId + " and key " + row.key)
if (row.documentId.startsWith("refill-device-SERIAL-")) {
obj = JSONObject(row.document.properties)
val canisters = gson.fromJson(obj.toString(), Canisters::class.java)
arrayList.add(canisters)
}
}
progressBarVisibility.postValue(0)
canistersArrayList.postValue(arrayList)
}
} catch (e: CouchbaseLiteException) {
e.printStackTrace()
}
}
liveQuery?.start()