MayoMayn
BestDev
- Oct 18, 2016
- 1,423
- 683
So basically I'm exporting a top level object in Scala.js where the start method takes in a JS object as function argument.
After some
This is my main.scala file:
Then from my index.html I call the method:
Any clue how to solve this?
My bad it actually did work.
You just cant println the JS object and see the object structure, but when I logged "config.host" instead it did show "127.0.0.1"
After some
You must be registered for see links
I discovered that defining a trait for the object would solve the issue, but all I get is still "[Object object]"This is my main.scala file:
PHP:
package stormengine
import scala.scalajs.js.annotation._
import org.scalajs.dom
import scala.scalajs.js
@js.native
trait Config extends js.Object {
val host: js.UndefOr[String] = js.native
}
@JSExportTopLevel("StormEngine")
object StormEngine {
@JSExport
def start(config: Config): Unit = {
println(config)
}
}
Then from my index.html I call the method:
PHP:
<!DOCTYPE html>
<html>
<head>
<title>Example Scala.js application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="http://localhost:12345/workbench.js"></script>
</head>
<body style="margin: 0px">
<div id="game" />
<script type="text/javascript" src="../storm-engine-fastopt.js"></script>
<script>
StormEngine.start({
host: '127.0.0.1'
});
</script>
</body>
</html>
Any clue how to solve this?
My bad it actually did work.
You just cant println the JS object and see the object structure, but when I logged "config.host" instead it did show "127.0.0.1"