How should I call `window.setTimeout` ? ```public...
# webassembly
c
How should I call
window.setTimeout
?
Copy code
public abstract fun setTimeout(handler: kotlin.js.JsAny?, timeout: <http://kotlin.Int|kotlin.Int> /* = compiled code */, vararg arguments: kotlin.js.JsAny?): <http://kotlin.Int|kotlin.Int>
How should I convert a function into a JsAny?
i
Hi, it is invalid binding of course 😢. We need to regenerate them later. For now you can make your own binding:
Copy code
private fun setTimeout(window: Window, handler: () -> Unit, timeout: Int): Unit =
    js("window.setTimeout(handler, timeout)")

fun timer()  {
    val handler = {
        println("Hello timer")
    }
    setTimeout(window, handler, 1000)
}
or make a wrapper for handler:
Copy code
private fun wrapper(handler: () -> Unit): JsAny = js("handler")

fun timer()  {
    val handler = wrapper {
        println("Hello timer")
    }
    window.setTimeout(handler, 1000)
}