How can I read a text file with scala.js?

scala, scala.js

Solution

You can assign a lambda to the `onload` handler:

reader.onload = (e: UIEvent) => {
  // Cast is OK, since we are calling readAsText
  val contents = reader.result.asInstanceOf[String]
  println(contents) 
}

Problem

Basically I'm trying to figure out what I need to pass to the `onload()` method ``` def selectedFile(e: ReactEventI) = { val reader = new dom.FileReader() reader.readAsText(e.currentTarget.files.item(0)) reader.onload( ) } ```

Original source