与数据库相关的(Room)条件startDestination Android导航 [英] Database Dependent (Room) Conditional startDestination Android Navigation
问题描述
我正在设置条件startDestination,例如在这里看到:
I'm setting a conditional startDestination, as e.g. seen here:
https://stackoverflow.com/a/51961843/393607
问题:条件应取决于房间查询.当然,该查询不能在主线程上运行,MainActivity的onCreate必须等待查询完成后才能构建导航图.
The problem: The condition should depend on a room query. This query can't be run on the main thread of course, the onCreate of the MainActivity would have to wait for the query to be finished before constructing the navigation graph.
关于如何执行此操作的任何建议?
Any recommendations on how to go about this?
推荐答案
好的,很快.Kotlin的确很棒:将所有内容包装在 runBlocking {}
中就可以了.如果有人需要,我会把它留在这里.
Ok that was fast. Kotlin's really great: wrapping everything in runBlocking {}
did the trick.
I'll leave this here, in case somebody needs it.
这篇关于与数据库相关的(Room)条件startDestination Android导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!