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
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
fun CoroutineScope.safetyLaunch(block: suspend () -> Unit) {
|
||||
launch {
|
||||
fun CoroutineScope.safetyLaunch(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
block: suspend () -> Unit
|
||||
) {
|
||||
launch(context, start) {
|
||||
try {
|
||||
block.invoke()
|
||||
} catch (_: Throwable) { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue