subscribeAsync

fun <T, M> Flow<T>.subscribeAsync(scope: CoroutineScope, markerFactory: suspend (T) -> M, logger: KSLog = KSLog, block: suspend (T) -> Unit): Job(source)

Subscribes to a Flow with asynchronous processing based on markers. Each value from the flow will be processed by the block function. Values with the same marker will be processed sequentially in the same coroutine scope, while values with different markers can be processed concurrently in separate coroutine scopes.

Return

A Job representing the subscription that can be cancelled

Parameters

scope

The CoroutineScope in which to subscribe to the flow

markerFactory

A factory function that produces a marker for each emitted value

logger

The logger instance used for logging exceptions. Defaults to KSLog

block

The suspending function that processes each emitted value

Type Parameters

T

The type of values emitted by the flow

M

The type of markers used to group values