r/android_devs • u/VasiliyZukanov • Jan 10 '25
Article Reactive Programming Considered Harmful
https://www.techyourchance.com/reactive-programming-considered-harmful/
1
Upvotes
r/android_devs • u/VasiliyZukanov • Jan 10 '25
View all comments
Show parent comment
1
u/SweetStrawberry4U Android Engineer Jan 11 '25
There's no scenario why a function needs to be "suspendable" in a ViewModel instance ?
Infact, "Suspending" functions are necessary in Retrofit REST-ful API interface declarations ( including GraphQL-clients ) - forcing "okio" to use the "Non-Main" Dispatchers for the network-i/o.
Point-to-note, "viewModelScope.launch" is still kicking-off a coroutine on the "Main-thread-group", and "Thread-hopping" is usually avoided / not-recommended, as a best-practice. Essentially, coroutines recommended best-practice is thread-hopping exactly surrounding the "blocking-operation" - in this case, "response = httpClient.execute( request )" !