I have an issue regarding kotlin flow merging. See below fun.
suspend fun method(filter: String): Flow<List<Model>> {
// Search.
val models: List<Model> = repo.getModels(filter) // suspend function
// Get favorites
val favoritesFlow: Flow<List<Int>> = otherRepo.getFavorites()
// Return models as Flow, but mark/unmark every model as favorite when favoritesFlow is updated.
??? val result = models + favoritesFlow ????
return result
}
I need to return a flow of list of models, but when the favorite flow is changed, I have to mark or unmark each model as favorite. Do you have any idea how could I do this?