This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val parentJob = scope.launch { | |
val result1 = suspendFunction1() | |
var nonCooperativeChildResult = 0 | |
val nonCooperativeChild = launch { | |
while(isActive) { | |
nonCooperativeChildResult = | |
someRecursiveProcessing(nonCooperativeChildResult) | |
} | |
} | |
val result2 = async { someApiCallWithRetrofit() } | |
val result3 = callbackConvertedWithSuspendCancellable() | |
var combinedResult = result1 + result2.await() + result3 | |
nonCooperativeChild.cancel() | |
combinedResult += nonCooperativeChildResult | |
processResult(combinedResult) | |
} | |
// On cancel button clicked we can do either of the following parentJob.cancel() | |
scope.cancel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment