Doru N.
03/16/2021, 4:38 PMtimeout
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.ephemient
03/16/2021, 8:13 PMDoru N.
03/16/2021, 9:19 PMephemient
03/16/2021, 10:57 PMephemient
03/16/2021, 10:58 PMbaxter
03/17/2021, 5:59 AMbaxter
03/17/2021, 6:02 AMbaxter
03/17/2021, 6:17 AMflow {
emit("bar")
delay(100)
emit("baz")
delay(100)
emit("domo")
delay(1000)
emit("foo")
}.withTimeout(300).collect {
delay(500)
println(it)
}
The output would be:
> "bar"
> "baz"
> "domo"
> TimeoutException