Kotlin compose 如何知道挂起函数何时完成?

问题描述 投票:0回答:0

我在我的存储库中声明了我的注销功能,如下所示:

suspend fun doLogout() {
      //do logout
}

如何才能在这个函数完成后才运行另一个函数或代码?我可以知道功能何时完成吗? 我想这样做:

viewModelScope.launch(Dispatchers.IO) {
        repo.doLogout()
        isLogin = false 
      }

isLogin 应仅在 doLogout 完成时分配给 false

multithreading kotlin android-jetpack-compose kotlin-coroutines suspend
© www.soinside.com 2019 - 2024. All rights reserved.