Tolriq
11/02/2018, 9:35 AMabstract 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
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?