【问题标题】:how to get Deffered from DAO?如何从 DAO 获得延期?
【发布时间】:2019-04-10 10:54:16
【问题描述】:

我想让 Kotlin Coroutnies 从 DAO 中延迟

@Query("select * from gameprocess where cabinId = :cabinId ")
fun getAllGameProccesBiCabin(cabinId :Int) : Deferred<GameProcess>

但是它没有编译(房间不知道如何处理Deffered),但我需要使用'Deffered'中的'wait' 怎么办?

作为另一种选择,我可以使用这篇文章中的扩展功能,但是不知道如何将它集成到 dao 中:

https://codelabs.developers.google.com/codelabs/kotlin-coroutines/index.html?index=..%2F..index#6

【问题讨论】:

标签: android kotlin android-room


【解决方案1】:

这是允许我使用 async{}.await https://github.com/Kotlin/kotlinx.coroutines/blob/master/ui/coroutines-guide-ui.md 的依赖项

问题是我使用的是不支持它的旧版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-22
    • 2019-10-19
    • 2021-07-20
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    相关资源
    最近更新 更多