Trying to learn best practice but I'm having probl...
# android
t
Trying to learn best practice but I'm having problems to understand differences between
Copy code
abstract class ScopedAppActivity: AppCompatActivity(), CoroutineScope {
    protected lateinit var job: Job
    override val coroutineContext: CoroutineContext 
        get() = job + Dispatchers.Main
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        job = Job()
    }
        
    override fun onDestroy() {
        super.onDestroy()
        job.cancel()
    } 
}`
and
Copy code
abstract class ScopedAppActivity: AppCompatActivity(), CoroutineScope {
    override val coroutineContext = Dispatchers.Main + Job()
       
    override fun onDestroy() {
        super.onDestroy()
        coroutineContext.cancel()
    } 
}
Second form seems to do the exact same thing but way simpler. so wanted to know if there's any differences that are hard to spot?