https://kotlinlang.org logo
Title
a

AmrJyniat

10/02/2021, 9:42 AM
I want to combine multiple flows by
combine
function in variable x as following:
val x = combine(flow1, flow2) { (flow1, flow2) ->
    listOf(flow1, flow2)
}
when I call collect on x flow the result will be empty because flow1 and flow2 not ready yet, so I want to trigger collect on each flow gets ready to get latest data always.
d

Dominaezzz

10/02/2021, 9:54 AM
What do you mean by not ready yet?
a

AmrJyniat

10/02/2021, 10:02 AM
flow1 and flow2 are data from API which take some time to get ready.
d

Dominaezzz

10/02/2021, 10:24 AM
So? If it takes a while then the flow while suspend for a while.
☝️ 2
s

stojan

10/02/2021, 2:30 PM
flow1.onStart { emit(defaultValue) }
And the same for flow2
n

nilTheDev

10/02/2021, 6:55 PM
Isn't it normal that flows would take time to emit values? The consumer will wait then.