Lou*_*uis 9 android coroutine kotlin kotlin-coroutines
使用以下代码时出现编译错误:
暂停函数只能在协程体内调用
有人可以向我解释为什么吗?我需要做什么才能使它工作(不使用@Transaction注释)?
override suspend fun replaceAccounts(newAccounts: List<Account>) {
    database.runInTransaction {
        database.accountDao().deleteAllAccounts() // I have the error on this line
        database.accountDao().insertAccounts(newAccounts) // Here too
    }
}
@Dao
abstract class AccountDao : BaseDao<AccountEntity> {
    @Query("DELETE FROM Account")
    abstract suspend fun deleteAllAccounts()
}
在此先感谢您的帮助
| 归档时间: | 
 | 
| 查看次数: | 949 次 | 
| 最近记录: |