Last active
January 29, 2023 12:38
-
-
Save philipschwarz/d0ac49466acbb6d273082dc49751f8a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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