Something like that? ``` val channel = produce { ...
# coroutines
g
Something like that?
Copy code
val channel = produce {
  delay(500) // only one value with delay, but can be wrapped to some loop)
  send("some value")
}
for (value in channel) {
   //Do something
}
Depends on your case of course. What exactly do you want to do?
👍 1
a
I'm currently learning coroutines.
Observable.interval
emits an item every x TimeUnits. for example you can emit a value every 500 miliseconds for 10 times. From your code, I imagine it would be easy to implement, It just needs a
for
for how many times it should run and the timer needs to be inside
delay
. Thanks.
g
Yes, something like:
Copy code
val channel = produce {
   repeat(10) {
      delay(500)
      send("some value")
   }
}
a
That is neat. Thank you.