我可以通过存储库类中托管的retrofit.this代码从网络接收数据: val webService = AppModuleDO中的update方法suspend fun updateQuestions(list: List<Question>)
如果代码在我的viewModel中,我可以在viewModelScope.launch{}中运行挂起函数,我需要知道如何在仓库中运行R
我认为问题是我不知道如何很好地使用协程。在地图活动中,您将看到我访问了一个PointsDao暂停函数,该函数返回一个对象列表,我希望使用这些对象在我的Google Maps活动中创建标记。Int {}
// Gets the points from room repository through ViewModelDispatchers.IO).launch
在一个用Kotlin编写的Android项目中,我有一个数据结构,我想在单个线程上执行一些操作,因为两者都不是线程安全的,并且在它上执行操作的顺序很重要。我不希望这个线程成为主线程,因为操作很慢。我尝试过多种方式创建我的threadContext: val threadContext = newFixedThreadPoolContext(1, "Background") val isCurrent =