mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
safely fixes
This commit is contained in:
parent
14aa9ca26c
commit
a36828116e
@ -19,7 +19,7 @@ fun <T> CoroutineScope.actor(
|
||||
|
||||
inline fun <T> CoroutineScope.safeActor(
|
||||
channelCapacity: Int = Channel.UNLIMITED,
|
||||
noinline onException: ExceptionHandler<Unit> = {},
|
||||
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||
crossinline block: suspend (T) -> Unit
|
||||
): Channel<T> = actor(
|
||||
channelCapacity
|
||||
|
@ -16,7 +16,7 @@ inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend
|
||||
*/
|
||||
inline fun <T> Flow<T>.subscribeSafely(
|
||||
scope: CoroutineScope,
|
||||
noinline onException: ExceptionHandler<Unit> = { throw it },
|
||||
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||
noinline block: suspend (T) -> Unit
|
||||
) = subscribe(scope) {
|
||||
safely(onException) {
|
||||
|
@ -10,21 +10,6 @@ import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
private data class CallbackContinuationPair<T> (
|
||||
val callback: suspend SQLiteDatabase.() -> T,
|
||||
val continuation: Continuation<T>
|
||||
) {
|
||||
suspend fun SQLiteDatabase.execute() {
|
||||
safely(
|
||||
{
|
||||
continuation.resumeWithException(it)
|
||||
}
|
||||
) {
|
||||
continuation.resume(callback())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StandardSQLHelper(
|
||||
context: Context,
|
||||
name: String,
|
||||
|
Loading…
Reference in New Issue
Block a user