なにかっていうと、Scalaで書いたソースをJavascriptのソースにコンパイルするんだとか。
取りあえず、下記を参考にさせてもらい、やってみる。
Scala.jsが凄い − mizchi's blog
まずはサンプルプロジェクトをお借りする。
$ git clone https://github.com/sjrd/scala-js-example-app $ cd scala-js-example-app
そしてコンパイルがこんな感じらしい。
$ sbt $ sbt packageJS
そしたら下記ファイルを開いてみる。
太文字で「It works!」と表示されたらコンパイル成功。
そして下記がコンパイル元のScalaソース。
scala-js-example-app/src/main/scala/example/ScalaJSExample.scala
package example import scala.scalajs.js import js.Dynamic.{ global => g } object ScalaJSExample { def main(): Unit = { val paragraph = g.document.createElement("p") paragraph.innerHTML = "<strong>It works!</strong>" g.document.getElementById("playground").appendChild(paragraph) } /** Computes the square of an integer. * This demonstrates unit testing. */ def square(x: Int): Int = x*x }
このあとどうしようかw
0 件のコメント:
コメントを投稿