kotlin-flow-extensions / hu.akarnokd.kotlin.flow / kotlinx.coroutines.flow.Flow / groupBy

groupBy

@FlowPreview fun <T, K> Flow<T>.groupBy(keySelector: suspend (T) -> K): Flow<GroupedFlow<K, T>>

Groups the upstream values into their own Flows keyed by the value returned by the keySelector function.

@FlowPreview fun <T, K, V> Flow<T>.groupBy(keySelector: suspend (T) -> K, valueSelector: suspend (T) -> V): Flow<GroupedFlow<K, V>>

Groups the mapped upstream values into their own Flows keyed by the value returned by the keySelector function.