https://kotlinlang.org logo
#coroutines
Title
# coroutines
p

projectmoon

05/13/2019, 10:45 AM
i guess i could do something like:
Copy code
flow {
    while (true) { emit(x); delay(y); 
}
l

louiscad

05/13/2019, 12:45 PM
Yes, where x comes from your API call just before. Also, please, post everything in one message so replying in threads is more straightforward and the channel is not flooded too much (there's over 20K people in this Slack and over 2K in this channel)
p

projectmoon

05/13/2019, 12:51 PM
well now everyone has lots of unread notifications 😄
i will try to keep it to a thread
i need a fixed timer, though. emit/delay doesn't emulate a fixed timer, right?
l

louiscad

05/13/2019, 2:11 PM
What do you mean by "fixed"?
p

projectmoon

05/13/2019, 2:31 PM
if you want the timer to run every X amount of time, rather than have X amount of time between runs
l

louiscad

05/13/2019, 4:00 PM
You can use substraction for that, and write your inline suspending function to implement it only once.
p

projectmoon

05/13/2019, 4:27 PM
that seems to work, thanks