[:white_check_mark: Solved]How to start a multiple...
# coroutines
c
[ Solved]How to start a multiple flows that can be "switched off" when its is not needed. Scenario: 1. A
List<Message>
in the UI 2. messages =
mutableStateListOf<Message>
in viewModel 3. messages depends on two actions
getAllPaginated
or
search
4. In both cases we observe SQLite, but only one flow should be active at a single instant (user is either viewing all or is searching) 5. Flow is used at SQLite because new messages can come from the network Questions: 1. How to switch between
getAll
and
search
flow 2. When a new search happens the old
search
flow should be cancelled and a new one should start
Here we should enable/disable the flows
getAll
and
search
when the user action changes
Same question was asked on SO - Link
a
flatMapLatest operator is probably what you are looking for.
👍 1