Hello guys, just wanna know your opinion on this l...
# coroutines
d
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
When a job is complete, cancelling it is pointless. Since you're not breaking structured concurrency here, there's zero need.
d
so, are there no memory leak or something? It will destroy the job automatically?
d
Exactly
👍 1