updates in coroutines

This commit is contained in:
InsanusMokrassar 2021-03-29 17:57:36 +06:00
parent c4a08e52e5
commit 2d662f91b3
2 changed files with 22 additions and 6 deletions

View File

@ -5,6 +5,10 @@
* `Versions`:
* `Kotlin`: `1.4.31` -> `1.4.32`
* Add subproject `repos.cache`
* `Coroutines`:
* Rewrite `subscribeSafelyWithoutExceptions`
* Now `subscribeSafelyWithoutExceptions` will use default handler instead of skipping
* New extension `subscribeSafelySkippingExceptions`
## 0.4.30

View File

@ -25,13 +25,25 @@ inline fun <T> Flow<T>.subscribeSafely(
}
/**
* Use [subscribeSafelyWithoutExceptions], but all exceptions inside of [safely] will be skipped
* Use [subscribeSafelyWithoutExceptions], but all exceptions will be passed to [defaultSafelyExceptionHandler]
*/
inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(
scope: CoroutineScope,
noinline block: suspend (T) -> Unit
) = subscribeSafely(
scope,
{},
block
)
) = subscribe(scope) {
safelyWithoutExceptions {
block(it)
}
}
/**
* Use [subscribeSafelyWithoutExceptions], but all exceptions inside of [safely] will be skipped
*/
inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(
scope: CoroutineScope,
noinline block: suspend (T) -> Unit
) = subscribe(scope) {
safelyWithoutExceptions({ /* skip exceptions */ }) {
block(it)
}
}