有没有办法让可观察的查询检测相关实体何时发生变化并通知其订阅者?下面使用人和地址之间的一对一关系。我希望在某人的地址更改时通知该人员查询。
@Entity
data class Person(@Id val id: Long = 0) {
@Backlink
lateinit var homeAddress: ToOne<Address>
}
@Entity
data class Address(@Id var id: Long = 0) {
lateinit var person: ToOne<Person>
}
// Build a query for the parent
val query = boxStore.boxFor<Person>.().query().build()
query.find()
// I want to be notified when the address changes
query.subscribe(...)
// Update a child object
val address = person.homeAddress.target ?: return
val newAddress = address.copy(street="...")
boxStore.boxFor<Address>.put(newAddress)
这会按预期更新地址框,但不会通知人员查询。有什么办法可以做到这一点?