Hello. I am trying out Kotlin flow. I have this co...
# coroutines
k
Hello. I am trying out Kotlin flow. I have this code block but launchIn runs on main thread. How can i make it run on worker thread
Copy code
getDataUseCase().onEach { _ ->
    
}.launchIn(viewModelScope)
s
That's because viewModelScope uses the Main dispatcher. You can switch dispatcher using flowOn
k
Thanks 🙂