Hi, I have the following flow that im collecting t...
# coroutines
t
Hi, I have the following flow that im collecting to control my android activity loading state...
myAdapter.loadStateFlow
.distinctUntilChangedBy { it.refresh }
.filter { it.refresh is LoadState.NotLoading || it.refresh is LoadState.Error }
.collectLatest { loadState ->
// .. use loadState value to display correct layout
}
I only wish to process the latest value of
loadState
which i thought would be given to my
collectLatest
block however I recive additional values that I would like to filter out some how is it possible to collectLatest the "actual" latest value? I improved the situation somewhat by adding
.debounce(100L)
however I do not like this use of "magic values" as by adding this instruction i experience intermittent layout issues, e.g. my loading progress spinner is shown permanently
j
If you filter out values for success, how do you expect to get the event "value is loaded" to stop the loading spinner?
t
@Joffrey where am i filtering out "success"? my collect lastest does see all the loadstates i require to control my loading ui states. it just that I see historical values as well I want to know if theres an approach I can use to filter out the "older" values, especially the old error states as I keep seeing all error states that have been generated during a user "session", I only want to see the latest error state not all of them