FunkyMuse
06/23/2021, 3:47 PMcollectAsLazyPagingItems()
respect something like
flow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
or the data is updated even when the UI isn't in started mode?Alexandre Elias [G]
06/24/2021, 12:14 AMAlexandre Elias [G]
06/24/2021, 12:37 AMwithFrameNanos
in an Effect, but you can't do that here since the Effect lives in private code you can't modify. so using flowWithLifecycle
seems rightFunkyMuse
06/24/2021, 9:24 AMAlexandre Elias [G]
06/24/2021, 5:45 PMpagingDataFlow.collectAsLazyPagingItems()
waits for create lifecycle event, but is unaffected by stop and start events. whereas pagingDataFlow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED).collectAsLazyPagingItems()
is additionally paused between stop and start events.Alexandre Elias [G]
06/24/2021, 5:46 PMAlexandre Elias [G]
06/24/2021, 5:50 PMFunkyMuse
06/24/2021, 10:49 PMFunkyMuse
06/25/2021, 8:12 PMpagingData.flowWithLifecycle(LocalLifecycleOwner.current.lifecycle).collectAsLazyPagingItems()
it doesn't seem to display the data 😕Alexandre Elias [G]
06/29/2021, 5:09 AMAdam Powell
06/29/2021, 11:05 PMflowWithLifecycle
will return a new flow instance, I think what you may want is this:
val lifecycle = LocalLifecycleOwner.current.lifecycle
val lazyPagingItems = remember(pagingData, lifecycle) {
pagingData.flowWithLifecycle(lifecycle)
}.collectAsLazyPagingItems()
Adam Powell
06/29/2021, 11:05 PMremember
will make sure it doesn't reassemble a new flow chain on recomposition unless you truly have a different pagingData
source or lifecycle
for that recomposition