Move flow.concurrentMap to ktx

This commit is contained in:
LoveSy
2021-11-13 03:49:41 +08:00
committed by John Wu
parent b6affe06a5
commit be9b0c2e8f
2 changed files with 15 additions and 8 deletions
@@ -0,0 +1,13 @@
package com.topjohnwu.magisk.ktx
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flatMapMerge
import kotlinx.coroutines.flow.flow
@FlowPreview
inline fun <T, R> Flow<T>.concurrentMap(crossinline transform: suspend (T) -> R): Flow<R> {
return flatMapMerge { value ->
flow { emit(transform(value)) }
}
}