Skip to content

Instantly share code, notes, and snippets.

@manuelernesto
Created August 20, 2020 18:51
Show Gist options
  • Save manuelernesto/1ec92420cf73dea3bc0d2e163124c34e to your computer and use it in GitHub Desktop.
Save manuelernesto/1ec92420cf73dea3bc0d2e163124c34e to your computer and use it in GitHub Desktop.
open class StandardFragment:Fragment(),CoroutineScope {
private 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()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment