arrow-fx icon indicating copy to clipboard operation
arrow-fx copied to clipboard

Flow `Schedule` constructor

Open nomisRev opened this issue 5 years ago • 0 comments

A constructor to create a Flow from a given Schedule. Given a f: suspend () -> A and a Schedule<A, B> we can construct a Flow<B> that executes f according to the provided Schedule<A, B> on repeat.

Schedule.spaced(100.millis)
  .toFlow { i: Int -> println("Run # $i") }
  .collect() // Run # 1, Run # 2, ...

nomisRev avatar Dec 12 '20 10:12 nomisRev