https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

Ray

12/07/2020, 3:46 PM
Is their a need to wrap a DAO Room coroutine function with a withcontext(Dispatcher.io) block. Example
Query()
suspend fun getUser():User
Repository
suspend fun getUserFromDb():User {
return withcontext (<http://dispatcher.IO|dispatcher.IO>) {return data.getUser()}
}
Or does room handle making this db call on the background thread?
k

kevin.cianfarini

12/07/2020, 4:12 PM
#room
👍 1
m

myanmarking

12/08/2020, 2:48 PM
no need. just use suspend. room uses their own dispatchers
👍 1
2
12 Views