class DeepLinkPresenter(private val deepLinkView: DeepLinkView): CoroutineScope by CoroutineScope(Dispatchers.IO) { fun handleDeepLinkData(appLinkData: Uri) { launch { try { // stuff val result = processDeepLink(appLinkData) // stuff } catch (exception: Exception) { launch(Dispatchers.Main) { deepLinkView.showInfo("There was an error processing the message. ${exception.message}") } } } } fun clear() { coroutineContext.cancelChildren() } }