Norbi
01/25/2023, 9:41 PMfun main() {
runBlocking {
withContext(Job() + ...) {
...
}
}
}
What is the reason for creating a new Job
instance for the withContext()
call?
Thanks.Sam
01/25/2023, 10:02 PMwithContext(NonCancellable)
in that it will stop the jobs in the inner scope from being cancelled by a cancellation of the outer scope. It has no other effect.Casey Brooks
01/25/2023, 10:06 PMNorbi
01/26/2023, 8:09 AMDo you have an example in a library or something similarSorry, I don't find it, I've seen this pattern in Medium articles (of the same author) when I looked for some info...
Norbi
01/26/2023, 8:10 AMNo.
Copy codewithContext(Job())
is a weird thing that you should never do as it breaks structured concurrency (we should have forbidden it, but we cannot due to backwards compatibility)