joadar
11/30/2021, 9:01 PMdateFlow.collectLatest { date ->
repository.getContentFromDate(date).collect { result ->
I can change the date so the content update.
But I have a favorite feature on the content.
On the default date, the favorite is working well (I collect the new value) but when I update the date, the collect doesn’t work on favorite events.
What am I doing wrong?
Thanks.ephemient
11/30/2021, 9:05 PMdateFlow
.flatMapLatest { date ->
repository.getContentFromDate(date)
}
.collect { result ->
which will cancel the previous repository.getContentFromDate
collection on each new date
joadar
11/30/2021, 9:11 PMprivate val dateFlow: MutableStateFlow<Date> = MutableStateFlow(currentDate)
...
dateFlow.update {
date
}
Maybe is it wrong?override fun getContentFromDate(date: Date): Flow<Result<List<Content>>> = flow {
emit(Result.Loading)
...
}