Does anyone know if you create a retrofit interface with a suspending function, does retrofit automatically switch context to the IO dispatcher behind the scenes?
k
kevin.cianfarini
02/02/2023, 9:45 PM
The suspend functions are main safe. Operations are offloaded to an executor that’s an internal implementation detail of OkHttp
e
ephemient
02/02/2023, 9:45 PM
yep. it's not the
<http://Dispatchers.IO|Dispatchers.IO>
, but it does context switch and it is safe.
m
mattinger
02/02/2023, 9:46 PM
Thanks. That was my assumption, but i wanted to double check as one of my teammates asked in a code review.
k
kevin.cianfarini
02/02/2023, 9:46 PM
The only difference this would make to you is that you potentially won’t get “free” context switches between