Hi, I am trying to add a `delay` but I dont know h...
# orbit-mvi
r
Hi, I am trying to add a
delay
but I dont know how to do this as i get the error about not being in a suspend function when inside an `intent`block.
m
screenshot please!
r
Copy code
fun qrCodeFound(code: String) = intent {
    postSideEffect(ScanPassSideEffect.ShowSpinner)
    reduce {
        delay(1000)
        val passResult = decodeQrCode(code)
The
delay
won’t work as its not in a suspend function which is strange because I thought all
reduce
calls weer within a
viewmodelscope
on android?
m
reduce
is not a suspending block and for good reason. You should never do
delay
inside
reduce
as it locks up orbit’s event loop.
if you want to do the delay in this case, you should do it before
reduce
r
thanks, I moved out of reduce and its fine.
a
worth saying if
decodeQrCode
is expensive then that should also be moved outside of the
reduce
block too