Sam
10/24/2018, 12:46 PMJaroslav
10/24/2018, 12:49 PMpublic fun launchAndCatch(
onError: (Throwable) -> Unit,
function: suspend () -> Unit): Finalizable {
val ret = Finalizable()
val coroutineContext: CoroutineContext = Dispatchers.Main
GlobalScope.launch(coroutineContext) {
try {
function()
} catch (e: Throwable) {
onError(e)
} finally {
ret.onFinally?.invoke()
}
}
return ret
}
Jaroslav
10/24/2018, 12:49 PMJaroslav
10/24/2018, 1:43 PMKotlinx_coroutines_core_nativeCoroutineDispatcher
. How can I make it compile this with a library?Sam
10/24/2018, 2:42 PMJaroslav
10/24/2018, 2:48 PMJaroslav
10/24/2018, 2:52 PMSam
10/24/2018, 3:27 PM