mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-07 00:59:26 +00:00
add .kotlin in gitignore
This commit is contained in:
@@ -8,34 +8,34 @@ fun CoroutineScope.launchSafely(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend () -> Unit
|
||||
) = launch(context, start) {
|
||||
runCatchingSafely(onException) { block() }
|
||||
runCatchingSafely(onException, block = block)
|
||||
}
|
||||
|
||||
fun CoroutineScope.launchSafelyWithoutExceptions(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
onException: ExceptionHandler<Unit?> = defaultSafelyWithoutExceptionHandlerWithNull,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
block: suspend () -> Unit
|
||||
) = launch(context, start) {
|
||||
runCatchingSafelyWithoutExceptions(onException) { block() }
|
||||
runCatchingSafelyWithoutExceptions(onException, block = block)
|
||||
}
|
||||
|
||||
fun <T> CoroutineScope.asyncSafely(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
onException: ExceptionHandler<T> = defaultSafelyExceptionHandler,
|
||||
block: suspend CoroutineScope.() -> T
|
||||
block: suspend () -> T
|
||||
) = async(context, start) {
|
||||
runCatchingSafely(onException) { block() }
|
||||
runCatchingSafely(onException, block = block)
|
||||
}
|
||||
|
||||
fun <T> CoroutineScope.asyncSafelyWithoutExceptions(
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
start: CoroutineStart = CoroutineStart.DEFAULT,
|
||||
onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,
|
||||
block: suspend CoroutineScope.() -> T
|
||||
block: suspend () -> T
|
||||
) = async(context, start) {
|
||||
runCatchingSafelyWithoutExceptions(onException) { block() }
|
||||
runCatchingSafelyWithoutExceptions(onException, block = block)
|
||||
}
|
||||
|
@@ -10,8 +10,12 @@ fun CoroutineScope.LinkedSupervisorJob(
|
||||
additionalContext: CoroutineContext? = null
|
||||
) = coroutineContext.LinkedSupervisorJob(additionalContext)
|
||||
|
||||
fun CoroutineScope.LinkedSupervisorScope(
|
||||
|
||||
fun CoroutineContext.LinkedSupervisorScope(
|
||||
additionalContext: CoroutineContext? = null
|
||||
) = CoroutineScope(
|
||||
coroutineContext + LinkedSupervisorJob(additionalContext)
|
||||
this + LinkedSupervisorJob(additionalContext)
|
||||
)
|
||||
fun CoroutineScope.LinkedSupervisorScope(
|
||||
additionalContext: CoroutineContext? = null
|
||||
) = coroutineContext.LinkedSupervisorScope(additionalContext)
|
||||
|
Reference in New Issue
Block a user