Skip to content

Instantly share code, notes, and snippets.

@philipschwarz
Last active January 29, 2023 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipschwarz/d0ac49466acbb6d273082dc49751f8a5 to your computer and use it in GitHub Desktop.
Save philipschwarz/d0ac49466acbb6d273082dc49751f8a5 to your computer and use it in GitHub Desktop.
import cats.effect._
import cats.effect.unsafe.implicits.global
import fs2._
import java.time.Instant
import scala.concurrent.duration._
object Mine extends App {
val s =
Stream
.repeatEval(IO.realTimeInstant)
.meteredStartImmediately(1.second)
val result: IO[List[Instant]] = s.take(3).compile.toList
result.unsafeRunSync().foreach(println)
// 2023-01-29T12:28:09.753Z
// 2023-01-29T12:28:10.771Z
// 2023-01-29T12:28:11.768Z
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment