Enable DataObserver to observe T?, not only List<T>
还没有人认领这个 Issue。
评估
调研方向
先从 Query.subscribe、DataObserver 和 SubscriptionBuilder 入手,了解为什么 subscription 目前会暴露 List 结果,然后将该行为与 Query.findFirst() 和 Kotlin asFlow 示例进行比较。当提供一种有文档说明的方式来观察单个 nullable T,同时保留现有的多结果观察行为时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
I came across the DataObservers today and noticed, that when you call subscribe on a Query<T>, you will end in a List<T> as result which in my opinion is not what you want, e.g. if you want to find an entity by its id BUT also want to track the changes of this object, you would normally do this: boxStore.boxFor(T::class.java).query {}.findFirst() which would result in a T? result type. Now when i also want to track changes here, i wrap it in a flow (i use kotlin) like this:
@ExperimentalCoroutinesApi
fun <T> Query<T>.asFlow() = callbackFlow {
val subscription =
this@asFlow.subscribe()
.onError { cancel("Database error", it) }
.observer { data -> offer(data) }
awaitClose { subscription.cancel() }
}
Suddenly i have to deal with a List<T> due to the fact, that the SubscriptionBuilder returns a SubscriptionBuilder<List<T>>.
Please add a more precise way to differ between single and multiple values. Currently i need to implement workarounds for this, but that should be a standard behaviour
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
objectbox/objectbox-java 的其他 Issue
-
bug
难度 3/5 1-2 天 新手友好度 35/100
objectbox/objectbox-java#1226 · 2 条评论 ·
-
documentation enhancement
难度 4/5 3-5 天 新手友好度 48/100
objectbox/objectbox-java#1225 · 9 条评论 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
objectbox/objectbox-java#1223 · 1 条评论 · 4 个 reaction ·
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
objectbox/objectbox-java#1211 · 1 条评论 · 3 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 38/100
objectbox/objectbox-java#1198 · 1 条评论 ·
查看 objectbox/objectbox-java 的全部 Issue
相似的 Issue
-
Bug Java Platform: Java
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-java#6138 · 1 条评论 ·
-
bug needs triage p2
难度 2/5 1-3 小时 新手友好度 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 条评论 ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/rocketmq-dashboard#4654 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100