Pick the fix
A teammate wraps every Retrofit suspend call in withContext(Dispatchers.IO). What do you tell them?
Hint 1 of 1
Who does the I/O in a Retrofit suspend call?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A It's unnecessary: Retrofit suspend functions are main-safe; switch only for your own blocking work
Correct. OkHttp runs the I/O on its own threads.
Why not the others?
- B It's required, or the call runs on the main thread. Retrofit already suspends while OkHttp works elsewhere.
- C Use Dispatchers.Default instead. Still unnecessary for the network call.
- D Use runBlocking to be safe. That blocks a thread.