https://kotlinlang.org logo
Title
o

oday

11/15/2021, 1:18 PM
I would like to turn this into a sequential call like with Rx’s
andThen()
viewModelScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            petsRepository.getPets(this).collect { pets ->
                deviceRepository.getDevices(this).collect { devices ->
d

Dominaezzz

11/15/2021, 1:24 PM
First?
o

oday

11/15/2021, 1:25 PM
the first is the getPets call
not sure what you mean by first
d

Dominaezzz

11/15/2021, 1:28 PM
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

oday

11/15/2021, 1:28 PM
oh I see
yea ill try
r

rook

11/15/2021, 8:28 PM
Might have to write your own extension if you want to wait for non-error completion. Take a peek at
Flow::onCompletion
u

uli

11/15/2021, 8:39 PM
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