If we have two flows defined like this:
val someflow = flow {
emit("something")
}
and another flow defined like:
val stateFlow = MutableStateFlow("some value")
Is it possible to combine the two flows into a single flow that just emits the last value emitted by either someflow
or stateFlow
?
The idea is that stateFlow
might emit a value at some point in the future, but until that happens I just want whatever value someflow
last emitted. In the "combined" flow, I would like to just take the first value emitted by someflow
but then be able to observe the rest of the updates on stateFlow
.
It seems like this might be accomplished with a combine function, but I just want to emit the latest emitted value between the two flows, I don't care about what the last value of one flow was.