my state contains list of feeds, selected feed and...
# compose
m
my state contains list of feeds, selected feed and posts related to selected feed. every time feed is selected, I want to fetch/observe it’s posts. I tried doing it like this:
Copy code
val posts by snapshotFlow { selectedFeed }
      .filterNotNull()
      .flatMapLatest { observePostsUseCase(feedId = it.id) }
what happens is that
snapshotFlow
emits same item 6, 7 times, even if I put
.distinctUntilChanged
into the chain. should
snapshotFlow
emit only when
selectedFeed
changes? I thought maybe my feed class
equals
isn’t right but it works properly.
a
You need to remember the flow, otherwise each recomposition will create a new flow.
m
ooh I see. thank you very much!
👍 1