Skip to content

Instantly share code, notes, and snippets.

@mazzouzi
Last active June 14, 2022 09:16
Show Gist options
  • Save mazzouzi/3413ad46fd785471688933340375586f to your computer and use it in GitHub Desktop.
Save mazzouzi/3413ad46fd785471688933340375586f to your computer and use it in GitHub Desktop.
class BackgroundLeakPresenter(val view: BackgroundLeakInterface) {
private val exceptionHandler = CoroutineExceptionHandler { _, exception ->
// Log exception error to server
}
private val coroutineScope = CoroutineScope(Job() + exceptionHandler)
fun doSomeIntensiveWork() {
coroutineScope.launch {
delay(120000) // simulate intensive work
view.onIntensiveWorkDone()
}.invokeOnCompletion {
Log.d("Morad", "${it?.message}")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment