summaryrefslogtreecommitdiff
path: root/examples/crossBuilds/simple/js
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-02 16:46:59 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-02 16:46:59 -0800
commit78f7ed0303ea42fca8f4e1535ea800d12d2a80eb (patch)
tree0bded0822fcba8fdea5d6f318603ae324b70dac4 /examples/crossBuilds/simple/js
parenta33254276bd211bf33be86eeb871ddbfe36fdb47 (diff)
downloadhands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.tar.gz
hands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.tar.bz2
hands-on-scala-js-78f7ed0303ea42fca8f4e1535ea800d12d2a80eb.zip
tweaked cross-build example
Diffstat (limited to 'examples/crossBuilds/simple/js')
-rw-r--r--examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala7
-rw-r--r--examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala11
2 files changed, 12 insertions, 6 deletions
diff --git a/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala b/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala
new file mode 100644
index 0000000..d3b0278
--- /dev/null
+++ b/examples/crossBuilds/simple/js/shared/main/scala/simple/Simple.scala
@@ -0,0 +1,7 @@
+/*shared/main/scala/simple/Simple.scala*/
+package simple
+object Simple{
+ def formatTimes(timestamps: Seq[Long]): String = {
+ timestamps.map(Platform.format).mkString("\n")
+ }
+} \ No newline at end of file
diff --git a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
index 40f65f4..ee2f5da 100644
--- a/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
+++ b/examples/crossBuilds/simple/js/src/main/scala/simple/Platform.scala
@@ -1,18 +1,17 @@
-/*js/src/main/scala/simple/Platform.scala*/
+//js/src/main/scala/simple/Platform.scala
package simple
import scala.scalajs.js
object Platform extends js.JSApp{
def format(ts: Long) = {
- new js.Date(ts).toLocaleString();
+ new js.Date(ts).toLocaleString()
}
def main() = {
- println("simple.js")
val times = Seq(
System.currentTimeMillis(),
- System.currentTimeMillis() + 1000,
- System.currentTimeMillis() + 2000
+ System.currentTimeMillis() + 1000
)
- println(Simple.formatTimestamps(times))
+ println("Running on JS! " + 1.0d)
+ println(Simple.formatTimes(times))
}
} \ No newline at end of file