Hello, got a question on coroutines Flow.
Is there a way of replicating RxJava
timeout
operator on Kotlin Flow? Namely, for my use case, I want to emit values from a Flow downstream, until a timeout happened (timeout duration should reset after every new emission), then stop emitting (no error) ?
The closest impl I see to what I need is the
debounce
operator, with the diff that I need to close / complete the flow when timeout happens.
thank you, this seems like it does the trick. one question: why did you had scope be as a parameter? (would creating a coroutineScope {} inside this function be more appropriate?)
e
ephemient
03/16/2021, 10:57 PM
can't call coroutineScope {} inside the function, it's not in the right context
ephemient
03/16/2021, 10:58 PM
kotlinx.coroutines internally has scopedFlow {} but it's not public