Is there something like `combine` but for when the...
# coroutines
m
Is there something like
combine
but for when the flows (arguments) are calculated based on the item in the main flow? My use case is a flow of
Item
s where each
Item
has a number of properties whose values are provided by flows. Initially those properties are null and so the operator I’m trying to implement, would transform an
Item
such that the properties are populated and the resulting Flow will emit a new
Item
each time any of the properties updates (as well as when the original flow emits a new
Item
).
t
Are you looking for a map operator? For example:
val nameLength = username.map { name(a string type) -> name.length }
m
A map is one-to-one, so I don’t see how that can help. My current hack creates the ‘property’ flows in
onEach
and then combines those.
t
Do you want to end up with multiple flows from a single flow?
m
Ideally, a single result flow from a single source flow, but with multiple property flows injecting values. The resulting flow would be potentially emitting far more items than the source flow. The items (of the resulting flow) are emitted whenever any of the ‘property’ flows emit. However, when the source ‘item’ flow emits, the old ‘property’ flows are discarded and new ones created.
r
Sounds like you want a
flatMapLatest
on the outer flow returning a zip/combine on the inner flows?
m
@Robert Williams I think you’re right, thanks! I’ll give it a shot