Hello guys, just wanna know your opinion on this launch. The this.cancel() will cancel the coroutine? Do I need to track the scope and finish it when the class is destroyed? Might main go here is launch and forget.
Copy code
CoroutineScope(Default).launch {
//do on background
formDataDTO?.ad?.characteristics?.find { it.id == GENERATION }?.let { cha ->
withContext(Main) {
//do on ui thread
characteristicBinder.bind(cha)
}
}
this.cancel("has done his job")
}
l
louiscad
04/24/2020, 11:50 AM
When a job is complete, cancelling it is pointless. Since you're not breaking structured concurrency here, there's zero need.
d
Diogo Ribeiro
04/24/2020, 12:34 PM
so, are there no memory leak or something? It will destroy the job automatically?