Ray Rahke
03/16/2024, 9:03 AMwindow.onload()
. the documentation is either hard to find or nonexistantJoffrey
03/16/2024, 9:36 AMwindow.load()
should exist?
All I see is the load event and thus the window.onload
event listener that you can assign:
import kotlinx.browser.*
fun main() {
window.onload = { event ->
println("Received event $event")
}
}
Adam S
03/16/2024, 9:38 AMRay Rahke
03/16/2024, 5:10 PMRay Rahke
03/16/2024, 5:10 PMRay Rahke
03/16/2024, 5:10 PMType mismatch: inferred type is () -> Unit but Event was expected
Ray Rahke
03/16/2024, 5:16 PMwindow.onload?.invoke() { event ->
print("loaded")
}
e: Type mismatch: inferred type is ([Error type: Cannot infer a lambda parameter type]) -> Unit but Event was expected
e: Cannot infer a type for this parameter. Please specify it explicitly.
Ray Rahke
03/16/2024, 5:18 PMevent: Event ->
just gives me
Unresolved reference: Event
Robert Jaros
03/16/2024, 5:34 PMevent: dynamic
Ray Rahke
03/16/2024, 5:37 PMRay Rahke
03/16/2024, 5:37 PMimport kotlinx.browser.*
import org.w3c.dom.*
fun main() {
val kotlin = "🙂"
window.addEventListener("load") { event: dynamic ->
print("hello")
}
println(kotlin)
}
None of the following functions can be called with the arguments supplied: public final fun addEventListener(type: String, callback: ((Event) -> Unit)?, options: dynamic = ...): Unit defined in org.w3c.dom.Window public final fun addEventListener(type: String, callback: EventListener?, options: dynamic = ...): Unit defined in org.w3c.dom.Window
Ray Rahke
03/16/2024, 5:40 PM