I have a following Kotlin flow, what I need to do is emit the value from getUseCase.getResult() and then fire up another flow which depends on the getResults() and emit more values. Code in getContentUseCase.getContent().transform executes and emits the value as expected however value in getUseCase.getResult().transform is never emitted.
However, when I remove the flatMapConcat operator and its content then Im getting values emitted from getUseCase.getResult().transform. Not sure what's what's going on but how can I have working emit in both flows?
getUseCase.getResult().transform { response ->
when (response.networkState) {
NetworkState.Success -> {
val contentList = response.contentList
val result = ResultDomainModel(networkState = NetworkState.Success,
contentList = contentList)
emit(smartSearchContentListResult)
}
else -> emit(ResultDomainModel(networkState = contentListResponse.networkState))
}
}.flatMapConcat { response ->
val contentList = response.contentList
val contentItemList = arrayListOf<SmartSearchContentDomainModel>()
contentList.withIndex().asFlow().map { content ->
getContentUseCase.getContent().transform { contentResponse ->
contentItemList[content.index] = contentResponse
emit(ResultDomainModel(networkState = NetworkState.Success,
contentList = contentList,
contentItems = contentItemList))
}