I'm failing to compile a simple example of Binding.scala, and being a newbie, I have no intuition how to fix it. Maybe the README is slightly outdated? The example at https://github.com/ThoughtWorksInc/Binding.scala-sample is even older and causes deprecation warnings.
My code, which I basically stuck together from the README, and even simplified a bit:
import com.thoughtworks.binding.dom
import org.scalajs.dom.document
import scala.scalajs.js.annotation.JSExport
@JSExport
object SampleMain {
@dom
def table = {
<table border="1" cellPadding="5">
<thead>
<tr>
<th>Name</th>
<th>E-mail</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
}
@JSExport
def main(): Unit = {
dom.render(document.body, table)
}
}
fastOptJS
causes a compile error:
SampleMain.scala:25:9: overloaded method value render with alternatives:
[error] (parent: org.scalajs.dom.raw.Node,children: com.thoughtworks.binding.Binding[com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.raw.Node]],dummy: Unit)Unit <and>
[error] (parent: org.scalajs.dom.raw.Node,children: com.thoughtworks.binding.Binding.BindingSeq[org.scalajs.dom.raw.Node])Unit <and>
[error] (parent: org.scalajs.dom.raw.Node,child: com.thoughtworks.binding.Binding[org.scalajs.dom.raw.Node])Unit
[error] cannot be applied to (org.scalajs.dom.raw.HTMLElement, scala.xml.Elem)
[error] dom.render(document.body, table)
[error] ^
I suspected a problem with type inference and tried this type annotation: def table: com.thoughtworks.binding.Binding[org.scalajs.dom.html.Table]
but this caused another error:
SampleMain.scala:11:6: type mismatch;
[error] found : scala.xml.Elem
[error] required: com.thoughtworks.binding.Binding[org.scalajs.dom.html.Table]
[error] (which expands to) com.thoughtworks.binding.Binding[org.scalajs.dom.raw.HTMLTableElement]
[error] <table border="1" cellPadding="5">
[error] ^
I'd appreciate an explanation what is going wrong here.