https://kotlinlang.org logo
Title
i

iex

10/05/2020, 3:02 PM
Is it a good practice to create a new (
Completable
) subscription on click? I developed the habit lately to use a
PublishSubject
trigger and subscribe to it in
init
, but saw code again that uses the "subscription on tap" pattern and I'm wondering whether my pattern is overkill?
a

alexsullivan114

10/06/2020, 11:26 AM
What's the
Completable
doing? The only that that comes to my mind is if you're doing something like making a network call or doing something expensive you may want to
debounce
the source. Otherwise I don't see why creating a new
Completable
on tap is a bad move.
u

ursus

10/06/2020, 5:10 PM
depends if you want to control the paralelism somehow (switchmap, concatmap, debounce etc), if not, the it doesnt matter
i

iex

10/12/2020, 7:32 AM
network call
well, yeah, I can't think of reasons not to create a new subscription each time
(aside from what you mentioned, but I don't need this)