keshav kowshik
keshav kowshik

Reputation: 2374

Kotlin Flow - Android: Application gets stuck in flow combine and does not move ahead

I am trying to combine two flows and then send the value to a function and then collect the result.

My code never goes to second line of combine and never comes to collect results block.

What am I missing can anyone pls explain.

Below is my code:

viewModelScope.launch {

            combine(flow1, flow2){ model1: Model1, model2: Model2 ->
                performAction(model1, model2)
            }.collect {list ->
                updateState {
                    copy(isLoading = false, list = list)
                }
            }
        }

Code never goes into performAction function and progress keeps loading.

Please help

Upvotes: 1

Views: 1326

Answers (1)

Róbert Nagy
Róbert Nagy

Reputation: 7602

I'd suspect that one of your flows is actually empty.

Could you ensure that both of them are emitting values?

Upvotes: 2

Related Questions