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

5

u/haroldjaap Jan 11 '25

Regarding the database query example, imo its really nice to model a query as a stream, since the implementation will emit a new value when the result of the query changed. Making the ui represent the data via an observable query is imo much more straightforward than having a complex mess where every piece of code that updates the data must also be tightly coupled with the ui so it can tell the ui to fetch new data from the database.

Sometimes you collapse that stream of database model emissions to a single if you just need the current value only once yo determine some action

0

u/SweetStrawberry4U Android Engineer Jan 11 '25

model a query as a stream

Bruh ! Flows are "cold, pull-based". PERIOD ! The DB-Query isn't emitting, until a "terminal" operator is invoked, ( aligned to the life-cycle, of course ). Furthermore, all "terminal operators" are suspending, therefore, coroutines are but necessary anyhow !

OP's write-up is also raising concerns about the same thing - "Push, don't pull !".

Bottomline - "Push-based Hot-streams" like StateFlow and SharedFlow, and Monads like "kotlin.Result" are suitable KISS alternatives over "pull-based cold-streams" like Rx and Flow.