Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sleep to Pull #2456

Merged
merged 1 commit into from
Jul 2, 2021
Merged

Add sleep to Pull #2456

merged 1 commit into from
Jul 2, 2021

Conversation

nikiforo
Copy link
Contributor

@nikiforo nikiforo commented Jul 1, 2021

Added Pull.sleep, analogously to Stream.sleep.

import cats.effect.IOApp
import cats.effect.{ExitCode, IO}
import scala.concurrent.duration._
import cats.syntax.all._

object PullSleepApp extends IOApp {

  def run(args: List[String]): IO[ExitCode] =
    printTime
      .productR(Pull.sleep[IO](1.second))
      .productR(printTime)
      .stream
      .compile
      .drain
      .as(ExitCode.Success)

  private def printTime = Pull.eval(IO.delay(println(System.currentTimeMillis())))
}
[info] running fs2.PullSleepApp 
1625160228568
1625160229692

@mpilquist mpilquist merged commit a745d70 into typelevel:main Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants