Vivek Modi
01/17/2022, 10:53 PMcollectLatest is calling twice and sometimes even more. I printed the log inside my collectLatest function it print the log.Vivek Modi
01/17/2022, 10:54 PMMax Ferrier
01/18/2022, 7:19 AMLifecycle.State.STARTED , you'll have a new coroutine for states STARTED and RESUME. So, I would try to remove it because you already have the launchWhenStarted juste above.Vivek Modi
01/18/2022, 9:11 AMrepeatOnLifeCycle this but it didn't workMax Ferrier
01/18/2022, 9:16 AMtime or nothing ?Max Ferrier
01/18/2022, 9:18 AMVivek Modi
01/18/2022, 9:18 AMMax Ferrier
01/18/2022, 9:27 AMemptyList() and a second one with response.items .
In the doc, it says :
flow {
emit(1)
delay(50)
emit(2)
}.collectLatest { value ->
println("Collecting $value")
delay(100) // Emulate work
println("$value collected")
}
In the collect, the delay time is longer than in the flow. So if you send 20 values in your flow every 50ms, but your collect can treat only one value data in 100ms, you'll only work with the final value.
But if you send 20 values in your flow every 500ms, and your collect can still treat one value every 100ms, Vivek Modi
01/18/2022, 9:32 AMemptyList() and my collectLatest will call only once? Is it possible in flow?Max Ferrier
01/18/2022, 9:32 AMMax Ferrier
01/18/2022, 9:38 AMdata.isNotEmpty()Vivek Modi
01/18/2022, 9:49 AM