class Dog {
var name: String
var age: Int
var toys: List<Toy>
}
class Toy {
var brand: String
var name: String
}
If I’d like to observe Realm changes by observing Dogs Realm Results, filtering by using Keypaths I am not allowed to do:
let keyPath: PartialKeyPath<Dog> = [
\Dog.toys.brand
]
(I’d like to get observers when any toy’s brand name for a dog changes)
Realm documentation seems wrong, because ‘toys’ which is a List does not have a ‘brand’.
Objects in List can certainly be observed for changes - the documentation you linked is a tad out of date but it’s also covered in the SDK Docs
That being said, in the link you provided to that Realm article, I don’t believe this code is valid as I think the partial key path only works on single objects, not on a collection, results in this case.
let results = realm.objects(Company.self)
let notificationToken = results.observe(keyPaths: [\Company.orders.status]) { changes in
// update UI
}
which means that [\Company.orders.status] should be ["orders.status"] if orders is a List Property
It’s possible I have the syntax wrong as well so probably need another set of eyes on this.