objectbox / objectbox/objectbox-java
Only re-deliver query results if results have changed
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
Code example probably will be best description here.
@Entity
class KAEntry(
@Unique val key: String,
val value: String,
@Id var id: Long = 0
)
class MyApp : Application() {
private lateinit var subs1: DataSubscription
private lateinit var subs2: DataSubscription
private lateinit var boxStore: BoxStore
private set
override fun onCreate() {
super.onCreate()
boxStore = MyObjectBox.builder().name("main").androidContext(this).build()
val box = boxStore.boxFor(KAEntry::class.java)
box.removeAll() // just for reproducibility, to avoid "unique constraint violation" on second run of app
subs1 = box.query().equal(KAEntry_.key, "key1")
.build().subscribe().observer { v ->
Log.i("MyApp", "triggered for key1" )
}
subs2 = box.query().equal(KAEntry_.key, "key2")
.build().subscribe().observer { v ->
Log.i("MyApp", "triggered for key2" )
}
box.put(KAEntry("key1","some value"))
}
}
Problem is that even I've only put "key1" object and therefore only first query should trigger it's observer - both actually get triggered:
2021-04-05 14:22:53.263 25926-25962/com.acme I/MyApp: triggered for key1
2021-04-05 14:22:53.263 25926-25963/com.acme I/MyApp: triggered for key2
Either I don't understand something or this observer on query actually bugged.
I can see that triggering observer for only those objects that are changed and are in query result may have some performance impact. Though even in this case I would like to have some way of detecting that change was made to objects that query returns and not any object of this type.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件、测试或入口点。首先复现 Kotlin 查询订阅示例,然后跟踪查询观察者的实现及其测试(如果存在)。完成的标准是:只有当观察者的查询结果发生变化时才通知观察者,或者记录文档说明受支持的检测相关对象变化的方法。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- kotlin
- 领域
- databases, mobile-dev
- Issue 类型
- 缺陷
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100