Make safetyLaunch return Job
This commit is contained in:
parent
400dd718da
commit
5092fc9900
|
|
@ -2,6 +2,7 @@ package ru.touchin.extensions
|
|||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
|
@ -10,10 +11,9 @@ fun CoroutineScope.safetyLaunch(
|
|||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend () -> Unit
|
||||
) {
|
||||
launch(context, start) {
|
||||
try {
|
||||
block.invoke()
|
||||
} catch (_: Throwable) { }
|
||||
): Job = launch(context, start) {
|
||||
try {
|
||||
block.invoke()
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue