Skip to content

Instantly share code, notes, and snippets.

@alexandru
Created November 7, 2016 15:41
Show Gist options
  • Select an option

  • Save alexandru/0eb8e9e680305205ce3a5ff2e48c42bf to your computer and use it in GitHub Desktop.

Select an option

Save alexandru/0eb8e9e680305205ce3a5ff2e48c42bf to your computer and use it in GitHub Desktop.
import monix.eval.TaskApp
import monix.reactive.Observable
import scala.concurrent.Await
import scala.concurrent.duration._
// Variant 1 (classic)
object Playground {
def main(args: Array[String]): Unit = {
val completedF = Observable
.intervalAtFixedRate(5.seconds)
.foreach(_ => println("Tick!"))
Await.result(completedF, Duration.Inf)
}
}
// Variant 2 (more pure, using TaskApp)
object Playground2 extends TaskApp {
override def runc = {
Observable
.intervalAtFixedRate(5.seconds)
.foreachL(_ => println("Tick!"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment