Add context and start as params for safetyLaunch
This commit is contained in:
parent
64c4013f96
commit
e29bb344fd
|
|
@ -1,10 +1,17 @@
|
||||||
package ru.touchin.extensions
|
package ru.touchin.extensions
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.CoroutineStart
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
fun CoroutineScope.safetyLaunch(block: suspend () -> Unit) {
|
fun CoroutineScope.safetyLaunch(
|
||||||
launch {
|
context: CoroutineContext = EmptyCoroutineContext,
|
||||||
|
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||||
|
block: suspend () -> Unit
|
||||||
|
) {
|
||||||
|
launch(context, start) {
|
||||||
try {
|
try {
|
||||||
block.invoke()
|
block.invoke()
|
||||||
} catch (_: Throwable) { }
|
} catch (_: Throwable) { }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue