kingsley
03/18/2017, 4:32 PMclear
and cancel
on a composite disposable in Rx
I have a situation where the parent job should live longer than it's children.elizarov
03/18/2017, 4:34 PMkingsley
03/18/2017, 4:38 PMelizarov
03/18/2017, 4:41 PMrun(NonCancellable) { ... }
for bits of code that need to be running despite the fact the job was cancelled. Also, cancellation only affects suspending functions (cancellable suspending functions, to be precise), so if you are just cleaning up some data-structures or resetting some flags, none of that is going to be cancelled.kingsley
03/18/2017, 4:48 PMNonCancellable
instead of a simple Job()
as the parent. Does calling cancel on it cancel it's children, while itself remains at large?elizarov
03/18/2017, 6:38 PMJob
and pass its instance in the context of each child you start. That way you can cancel this job, while leaving the parent coroutine alone.deviant
03/18/2017, 6:55 PMfun onStop(){
job.cancel()// it would be nice to iterate through child jobs somehow and cancel them instead of cancelling parent
}
and when activity returns back to foreground we need to recreate the parent job because it was already cancelledkingsley
03/18/2017, 7:35 PMkenkyee
03/19/2017, 12:14 PMkingsley
03/19/2017, 1:19 PMkenkyee
03/19/2017, 1:20 PMkingsley
03/19/2017, 2:45 PM