Is it possible to create a flow operator similar t...
# flow
t
Is it possible to create a flow operator similar to
collect
with its own coroutine scope for each item it receives? E.g lets say I have an updating list of bicycles, a
Flow<List<Bicycle>>
. For each bicycle I can request a price, unfortunately this API requires me to request the prices for a single bicycle at a time. This is all fine i can spin up some requests using a couple of
async
builders, no problem so far. The API for requesting prices might be slow at times, slower than the stream of new bicycles that becomes available or taken. This however creates the issue of still be working on fetching prices for bikes that are no longer available or taken. Is there any way to create a coroutine scope for each item collected from my
Flow<List<Bicycle>>
and then cancel it when a new item is collected, If I understand correctly due to the sequential nature of flows, the next item is not requested until the previous is finished/completed?
w
create a coroutine scope for each item collected from my 
Flow<List<Bicycle>>
 and then cancel it when a new item is collected
This sounds like a
flatMapLatest { }
, perhaps?
t
The
*latest
functions are probably what I am after, thanks!
👍 1