Is there a reason why combine flow would not emit ...
# coroutines
k
Is there a reason why combine flow would not emit end result?
Copy code
val x = combine(y.invoke(), z.invoke()){ y+z }
Both
y
and
z
are flows of same type and they seem to not throw any errors.
b
You still have to collect that flow, combine returns just a cold transformed flow, it's not terminal operator
k
I am doing that with
collectAsState(initial = null)
but it keeps returning null, altho both
y
and
z
contain values. It's just that transform is never called.
f
combine is probably causing a new flow to get instantiated at each composition. Try moving the combine outside the composable so that all you do here is collect it
k
It seems that nested
.transformLatest
that is inside flow
y
causes an issue. Maybe I do not understand it enough, but changing to flow builder and emitting value solves an issue.
f
If you have a viewmodel do the combine there and expose the result