可观察查询是否有办法检测相关实体何时更改,并通知其订阅者?以下使用人与地址之间的一对一关系。我希望在一个人的地址发生变化时通知此人查询。
@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)
这会按预期更新地址框,但不会通知人员查询。有什么办法可以实现吗?