Is there a proper way to have the following code `...
# coroutines
t
Is there a proper way to have the following code
Copy code
combine(flow1,flow2) { slowJob() }.statein()
Have the slowjob cancelled when one of the source flow emit again?
j
I haven't used
combine
in a long time, but isn't it by default how it works? Is
slowJob()
cancellable?
t
It's not for now, but I still all all the results in the state if there was cancellation even just at the end it should not reach the state. With that said I'll try with adding explicit cancellation support as a first step.
So no there's no cancellation by default.
k
Copy code
combine(flow1, flow2, ::Pair).mapLatest { (a, b) -> slowJob(a, b) }.stateIn()
t
thanks that seems to work.