juan_gandhi: (VP)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2016-06-30 06:46 pm
Entry tags:

I love Scala.js

it's amazing

[identity profile] link0ff.livejournal.com 2016-07-01 05:40 pm (UTC)(link)
Is Scala.js to Scala like ClojureScript to Clojure?

[identity profile] juan-gandhi.livejournal.com 2016-07-01 06:51 pm (UTC)(link)
I know nothing about ClojureScript (and not much about Clojure).
Here's a tutorial sample:
package com.xxx
import org.scalajs.dom
import dom.document

import scala.scalajs.js.annotation.JSExport
import scala.scalajs.js.{Date, JSApp}

object XXXWebApp extends JSApp {
  def main(): Unit = {
    println("Hello XXX! " + new Date())

    appendPar(document.body, "Hello RXI! it is " + new Date())
  }

  @JSExport
  def addClickedMessage(): Unit = {
    appendPar(document.body, "You clicked the button at " + new Date())
  }

  def appendPar(targetNode: dom.Node, text: String): Unit = {
    val parNode = document.createElement("p")
    val textNode = document.createTextNode(text)
    parNode.appendChild(textNode)
    targetNode.appendChild(parNode)
  }
}


with HTML looking like this:
  <body>
    <script type="text/javascript" src="./target/scala-2.11/rxi-web-client-fastopt.js">
    <script type="text/javascript">
      const GOD = com.rxi.RxiWebApp()
      GOD.main();
    </script>
    <button id="click-me-button" type="button"
            onclick="GOD.addClickedMessage()">Click me!
  </body>

[identity profile] yussouf.livejournal.com 2016-07-05 09:13 pm (UTC)(link)
GWT 2.0?

ггг