I’m using this for basically all of my viewModels-...
# coroutines
s
I’m using this for basically all of my viewModels- is there a more concise/kotlinesque way to write the coroutine + error handling + networking logic, and should I be using a specific dispatcher for networking?
Copy code
fun updateUserLang(user: UpdateUser) {
        viewModelScope.launch {
            try {

                val lang = repository.updateUser(user).data.attributes!!.locale

                _networkCallSuccess.postValue(Pair(lang!!, true))

            } catch (e: HttpException) {
                println("error: ${e.localizedMessage}")
            }
        }
    }
d
You can add a coroutine exception handler to the scope's context.
s
That’s definitely interesting - I don’t understand the advantage though.