safely fixes

This commit is contained in:
InsanusMokrassar 2020-12-22 15:42:11 +06:00
parent 14aa9ca26c
commit a36828116e
3 changed files with 2 additions and 17 deletions

View File

@ -19,7 +19,7 @@ fun <T> CoroutineScope.actor(
inline fun <T> CoroutineScope.safeActor( inline fun <T> CoroutineScope.safeActor(
channelCapacity: Int = Channel.UNLIMITED, channelCapacity: Int = Channel.UNLIMITED,
noinline onException: ExceptionHandler<Unit> = {}, noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
crossinline block: suspend (T) -> Unit crossinline block: suspend (T) -> Unit
): Channel<T> = actor( ): Channel<T> = actor(
channelCapacity channelCapacity

View File

@ -16,7 +16,7 @@ inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend
*/ */
inline fun <T> Flow<T>.subscribeSafely( inline fun <T> Flow<T>.subscribeSafely(
scope: CoroutineScope, scope: CoroutineScope,
noinline onException: ExceptionHandler<Unit> = { throw it }, noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
noinline block: suspend (T) -> Unit noinline block: suspend (T) -> Unit
) = subscribe(scope) { ) = subscribe(scope) {
safely(onException) { safely(onException) {

View File

@ -10,21 +10,6 @@ import kotlin.coroutines.Continuation
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException 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( class StandardSQLHelper(
context: Context, context: Context,
name: String, name: String,