Join Slack
Powered by
Hello. I am trying out Kotlin flow. I have this co...
# coroutines
k
Khan
04/04/2022, 11:51 AM
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
stojan
04/04/2022, 12:00 PM
That's because viewModelScope uses the Main dispatcher. You can switch dispatcher using flowOn
k
Khan
04/04/2022, 1:11 PM
Thanks 🙂
4
Views
Open in Slack
Previous
Next