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

takahirom

03/08/2021, 10:46 AM
I have a question about the interpretation of the following sentences. Does this mean it's a good practice to use withContext{} in all functions, even if there is no blocking process in the Repository?
A good practice is to use 
withContext()
 to make sure every function is main-safe, which means that you can call the function from the main thread.
https://developer.android.com/kotlin/coroutines/coroutines-adv#main-safety
🚫 1
a

Adam Powell

03/08/2021, 2:43 PM
No, only if it would block the calling thread
👍 2
u

uli

03/08/2021, 4:43 PM
That’s because it is already
main-safe
if it is not blocking.
2
4 Views