blue-sky
blue-sky

Reputation: 53916

dom.setInterval not available on ScalaJS

I'm following tutorial http://www.lihaoyi.com/hands-on-scala-js/#MakingaCanvasApp and it provides code :

  dom.setInterval(() => run, 50)

But this causes a compiler error :

object setInterval is not a member of package org.scalajs.dom  

How to set the interval on the dom ? It appears this method has been removed instead of deprecated ?

Upvotes: 1

Views: 934

Answers (1)

sjrd
sjrd

Reputation: 22105

It is still available under dom.window.setInterval, I think.

However, you should use scala.scalajs.js.timers.setInterval instead:

import scala.scalajs.js

js.timers.setInterval(50) {
  run
}

Upvotes: 5

Related Questions