https://kotlinlang.org logo
#android
Title
# android
m

matt tighe

12/14/2018, 9:19 PM
is it possible to post values to a mutable livedata from a coroutine? i’m trying to emit state updates from a long-running background process. something like this: (apologies for using experimental still)
Copy code
fun doLongProcess() = runBlocking {
    async {
        state.postValue("starting process")
        startLongProcess()
    }
}
r

rkeazor

12/15/2018, 3:28 PM
You should use the 1.0 version. Time to upgrade, the IDE will help you migrate once you update. I would think so, just remember to use CoroutineScope, and Dispatchers.MAIN
m

Mark Buikema

03/22/2019, 3:47 PM
withContext(Dispatchers.MAIN) { liveData.postValue(xxx) }
2 Views