Room will use different Dispatchers for transactions and queries. These are derived from the executors you provide when building your Database or by default will use the Architecture Components IO executor. This is the same executor that would be used by LiveData to do background work.
I can run db calls without making them suspend functions. How do I decided if those should be made
suspend
functions or not?
g
gildor
06/09/2021, 3:21 AM
I can run db calls without making them suspend functions
Of course you can, but my point that if you already use them with coroutines, you shouldn’t do that
Without “suspend” those db calls compiled to standard blocking functions, which not safe to use from main thread (or even any other suspend functions)(), so it’s a lot better to make them suspend, as described in article above
s
Sudhir Singh Khanger
06/09/2021, 4:43 AM
Thanks Andrey. That was very helpful. Thank you for taking the time to reply.