https://kotlinlang.org logo
Title
i

ilyagulya

08/19/2019, 4:08 PM
Hello, guys! How could you do such thing?
val a: Completable
val b: Completable
val c: Completable

val merged = Completable.merge(listOf(a,b))
I need to subscribe to both
merged
and
c
but if
merged
completes before the
c
, I need to unsubscribe from
c
.
k

kioba

08/19/2019, 4:10 PM
e

Eugen Martynov

08/19/2019, 6:21 PM
takeFirst(merged, c)
?
i

ilyagulya

08/19/2019, 7:27 PM
@kioba thanks! That’s exactly what I need!
👍 1
@kioba oops, sorry, this behaves the same as
takeFirst
.
@Eugen Martynov
takeFirst
will complete once any of completables are complete. I need
merged
to be completed for sure, but I don’t care if
c
will complete or not.
e

Eugen Martynov

08/19/2019, 7:38 PM
in side effect of the completing
merged
just cancel
c
disposable?
It will work and I don’t know any operator that will work as you said
unless you make your own
i

ilyagulya

08/19/2019, 10:55 PM
I've solved it.
merged
    .andThen(Completable.error(Exception()))
    .mergeWith(c)
    .onErrorComplete()