Here is an example using Timer from scala.rx:
package tutorial.webapp
import akka.actor.ActorSystem
import rx.core.{Rx, Var}
import rx._
import rx.ops._
import scala.concurrent.Promise
import scala.concurrent.duration._
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scala.concurrent.ExecutionContext.Implicits.global
/**
* Created by IDEA on 29/10/15.
*/
object RxAddtionalOps extends JSApp {
@JSExport
override def main(): Unit = {
timer1
}
def timer1: Unit = {
implicit val scheduler = new DomScheduler
val t = Timer(100 millis)
var count = 0
val o = Obs(t){
count = count + 1
println(count)
}
}
}
When you run runMain tutorial.webapp.RxAddtionalOps
from sbt, the console will be indefinitely blocked. Can I set a limit to the timer? For example, to make it stop emitting events in 2 minutes.