Trym Nilsen
10/05/2020, 4:09 PMcollect
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?wasyl
10/05/2020, 4:11 PMcreate a coroutine scope for each item collected from myThis sounds like aand then cancel it when a new item is collectedFlow<List<Bicycle>>
flatMapLatest { }
, perhaps?Trym Nilsen
10/05/2020, 4:50 PM*latest
functions are probably what I am after, thanks!