`just(1, 2, 3)` -> `flowOf(1, 2, 3)` `error(Exc...
# coroutines
j
just(1, 2, 3)
->
flowOf(1, 2, 3)
error(Exception())
->
flow { throw Exception() }
😍 1
t
Sorry to start a thread here, but i got another one. What would be the equivalent for Observable.create? Also this is probably use case specific. Let’s say i would want a thread to wait and then throw an error after a few seconds
Copy code
flow { 
            try {
                Thread.sleep(3000)
            } catch (e: InterruptedException) {
                e.printStackTrace()
            }
            this.emit(throw whateverException)
}
j
Change
Thread.sleep
to
delay
t
oh, yeah, sry
thanks
j
RxJava has a
delaySubscription
operator but I don't think there's a flow equivalent
👍 1
t
im also not sure about the throw, could i leave it out?
j
you would either throw or emit
t
ok, so leaving it out then
Okay, i have another question, is there an equivalent to RxJava
doOnNext
and
doOnComplete
?
Flow.onEach
?
👍 1
l
There are the
delayEach
and the
delayFlow
operators.
🤘 1