mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-26 03:58:45 +00:00
CoroutineScope#safeActor
This commit is contained in:
parent
6f5c6e5ebe
commit
dccb479c3c
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
* `Coroutines`
|
* `Coroutines`
|
||||||
* Function `safelyWithoutExceptions`
|
* Function `safelyWithoutExceptions`
|
||||||
|
* Extension `CoroutineScope#safeActor`
|
||||||
|
|
||||||
## 0.2.4
|
## 0.2.4
|
||||||
|
|
||||||
|
@ -17,3 +17,15 @@ fun <T> CoroutineScope.actor(
|
|||||||
return channel
|
return channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <T> CoroutineScope.safeActor(
|
||||||
|
channelCapacity: Int = Channel.UNLIMITED,
|
||||||
|
noinline onException: ExceptionHandler<Unit> = {},
|
||||||
|
crossinline block: suspend (T) -> Unit
|
||||||
|
): Channel<T> = actor(
|
||||||
|
channelCapacity
|
||||||
|
) {
|
||||||
|
safely(onException) {
|
||||||
|
block(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user