I have a problem: I use Xcode and Swift in addition to the latest Couchbase Mobile Solution. LiveQuery also works perfectly, if I use the String "rows" in order to register the Observer and then listen to it. But I have a view in my app, where I need two livequerys. So I intended to make two livequeries with two different key paths, for example the first one "getTopicComments", and the second one "getTopicDetails", so I could differenciate between them like below. But as I said, it only works for the key path "rows". Am I misunderstanding sth? Because I totally don't understand why it doesn't work with another String. In my opinion and as I read in the documentation of couchbase it shouldn't be relevant which String I use when registering the live query.
liveQueryOne.addObserver(self, forKeyPath: "getTopicComments", options: .new, context: nil)
liveQueryTwo.addObserver(self, forKeyPath: "getTopicDetails", options: .new, context: nil)
and
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if (keyPath == "getTopicComments") {
} else if (keyPath == "getTopicDetails") {
}
}
"rows" is a KVO observable property on CBLLiveQuery. That is why you can add an observer and look for KVO notifications. The idea behind live queries is that the app can be automatically notified of changes to database that affect the results of the query. The "rows" property will be updated when database updates and that's why you observe this property to be informed of changes. The keyPaths that you added above do not exist in CBLLiveQuery, so you will not see any notifications.