I would like to turn this into a sequential call l...
# coroutines
o
I would like to turn this into a sequential call like with Rx’s
andThen()
Copy code
viewModelScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            petsRepository.getPets(this).collect { pets ->
                deviceRepository.getDevices(this).collect { devices ->
d
First?
o
the first is the getPets call
not sure what you mean by first
d
There's a function called first() that you can use on the flow.
I'm on my phone so I can't write the code out.
o
oh I see
yea ill try
r
Might have to write your own extension if you want to wait for non-error completion. Take a peek at
Flow::onCompletion
u
You could make getPets a suspend function instead of making it a flow. Remember Flowable is comparable to Flow while Single is comparable to a simple suspend function