After migrating to androidx, my room repositories based on LiveData and GlobalScope.launch stopped working.
I changed GlobalScope.launch to GlobalScope.async, because i got exception with observeForever (but I event don't use this method).
val success = MediatorLiveData<SomeDataModel>()
try {
GlobalScope.async(Dispatchers.IO) {
success.addSource(myDao.getAll()) {
it?.let {
success.postValue(it)
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
return success
}
I want to point that before migrating to androidX this code worked.