Sudhir Singh Khanger
06/08/2021, 4:37 AMRoom 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.Does that mean if I use
withContext(<http://Dispatchers.IO|Dispatchers.IO>) { //db calls }Architecture Components IO executor<http://Dispatchers.IO|Dispatchers.IO>Defaultmaingildor
06/08/2021, 5:20 AMgildor
06/08/2021, 5:22 AMSudhir Singh Khanger
06/08/2021, 11:50 AMsuspendgildor
06/09/2021, 3:21 AMI can run db calls without making them suspend functionsOf 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
Sudhir Singh Khanger
06/09/2021, 4:43 AM