Android 当我们对某个用户进行身份验证时,是否需要添加livedata?

Android 当我们对某个用户进行身份验证时,是否需要添加livedata?,android,kotlin,android-lifecycle,observer-pattern,android-livedata,Android,Kotlin,Android Lifecycle,Observer Pattern,Android Livedata,我是android新手,也是在这个MVVM模式中,我看到一些教程,其中使用了livedata来获取用户数据,并在一些会话相关类中检查经过身份验证的用户。据我所知,当需要更新某些数据时,会使用livedata来监听实现可观察模式的更改。我在这里使用kotlin协程获取用户响应: Coroutines.main { try { val loginresponse = repository.userLogin(email!!, password!

我是android新手,也是在这个MVVM模式中,我看到一些教程,其中使用了livedata来获取用户数据,并在一些会话相关类中检查经过身份验证的用户。据我所知,当需要更新某些数据时,会使用livedata来监听实现可观察模式的更改。我在这里使用kotlin协程获取用户响应:

Coroutines.main {
            try {
                val loginresponse = repository.userLogin(email!!, password!!)
                loginresponse.token.let {
                    val keys = listOf("TOKEN", "USERNAME", "USERID")
                    val values = listOf(
                        loginresponse.token,
                        loginresponse.username,
                        loginresponse.id.toString()
                    )
                    repository.saveUserInfo(prefs, keys, values)
                    authListener?.onSuccess(it)
                    val intent = Intent(mContext, Sos::class.java)
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
                    mContext.startActivity(intent)
                }
            } catch (e: ApiException) {
                authListener?.onFailure(e.toString())

            } catch (e: NoInternetException) {
                authListener?.onFailure(e.message!!)
            }
}
使用协同路由可以吗?或者我应该使用livedata修改用户以在某个会话管理类中使用它吗