Created
November 7, 2016 15:41
-
-
Save alexandru/0eb8e9e680305205ce3a5ff2e48c42bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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