The Hidden Dangers of Room Database Performance (And How to Fix Them)
['Subhankar Bag']
ProAndroidDev - Medium
To be precise: the outdated part isn’t where the call lives — it’s the manual Dispatchers.IO wrapping around a suspend function that's already main-safe. fun getAllUsers(): List<User> // No suspend = blocks whatever thread calls it Room suspend functions are main-safe — no dispatcher needed at the call site Main-safety is the implementation’s job — withContext belongs inside your Repository/DataSource impl, never in the ViewModel Use viewModelScope.launch without explicit dispatchers when calling main-safe suspend functions Switch contexts only for: CPU work → Dispatchers.Default , blocking non-suspend I/O → Dispatchers.IO Always prefer suspend functions over blocking ones