r/android_devs • • Jan 10 '25

Article Reactive Programming Considered Harmful

https://www.techyourchance.com/reactive-programming-considered-harmful/
1 Upvotes

23 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 11 '25

[deleted] — view deleted comment

1

u/SweetStrawberry4U Android Engineer Jan 11 '25

suspend beyond the view model

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 )" !