mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-06 08:40:19 +00:00
fixes in actorAsync
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.micro_utils.coroutines
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
@@ -7,13 +8,15 @@ import kotlinx.coroutines.flow.consumeAsFlow
|
||||
fun <T> CoroutineScope.actorAsync(
|
||||
channelCapacity: Int = Channel.UNLIMITED,
|
||||
markerFactory: suspend (T) -> Any? = { null },
|
||||
logger: KSLog = KSLog,
|
||||
block: suspend (T) -> Unit
|
||||
): Channel<T> {
|
||||
val channel = Channel<T>(channelCapacity)
|
||||
channel.consumeAsFlow().subscribeAsync(this, markerFactory, block)
|
||||
channel.consumeAsFlow().subscribeAsync(this, markerFactory, logger, block)
|
||||
return channel
|
||||
}
|
||||
|
||||
@Deprecated("Use standard actosAsync instead", ReplaceWith("actorAsync(channelCapacity, markerFactory, block = block)", "dev.inmo.micro_utils.coroutines.actorAsync"))
|
||||
inline fun <T> CoroutineScope.safeActorAsync(
|
||||
channelCapacity: Int = Channel.UNLIMITED,
|
||||
noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,
|
||||
|
Reference in New Issue
Block a user