Simon
09/01/2021, 3:00 PMappmattus
09/02/2021, 12:32 AMfilterFlow.mapLatest { filter ->
getResultFlowBasedOnFilter(filter)
.collect {
...
}
}
filterFlow
could simply be a MutableStateFlow
@Mikolaj Leszczynski anything else come to mind?Mikolaj Leszczynski
09/02/2021, 8:31 AMmapLatest
is a nice idea for a filter implementation! I’d use a Channel
to keep the separation.
override val container = container(initialState) {
setupFilter()
}
private val filterChannel = channel(Channel.BUFFERED)
private val setupFilter() = intent {
filterChannel.receiveAsFlow()
.mapLatest { filter ->
getResultFlowBasedOnFilter(filter)
}
.collect {
...
}
}
fun filter(filter: String) = intent {
filterChannel.send(filter)
}
Mikolaj Leszczynski
09/02/2021, 8:33 AMJob
in your state to enable later cancellation of a Flow
Mikolaj Leszczynski
09/02/2021, 8:34 AMSimon
09/02/2021, 8:45 AMappmattus
09/02/2021, 3:12 PMintent(registerIdling = false) { ... }
. to be fair we need to create a lint rule around this if we can get some sort of detection working as its not obvious