I want to make a generic class that combines and array of flows, runs a transformer and emits the result (the class should do more than this, so thats the reason to put it in a class rather than a function)
this small example explains the problem
Copy code
class FlowGroup<T>(
items:List<MutableSharedFlow<T>>,
transform: suspend (Array<T>) -> T
) {
val flow = MutableSharedFlow<T>()
init {
MainScope().launch {
combine(items, transform).collect {
flow.emit(it)
}
}
}
}
combine
wont compile in this code because it uses the
reified
qualifier, and I don’t know how to get that into this function. Any suggestions?