我是Scala的新手,由于一些要求,我需要运行列出here的Rescala(反应式Scala)程序。例如,要运行 clickcounter 应用程序,我该怎么办?任何投入都会有很大的帮助。
答案 0 :(得分:0)
尝试scala console
,
安装sbt(简单构建工具) - https://dl.bintray.com/sbt/native-packages/sbt/0.13.13/sbt-0.13.13.tgz
创建一个空文件夹
build.sbt
文件
// rescala依赖
scalaVersion := "2.11.8"
resolvers += Resolver.bintrayRepo("rmgk", "maven")
resolvers += Resolver.bintrayRepo("pweisenburger", "maven")
// %% will use the scalaVersion defined for scala
libraryDependencies += "de.tuda.stg" %% "rescala" % "0.19.0"
sbt console
命令,该命令将为您下载rescala
//你会看到一些日志
sbt console
info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading https://dl.bintray.com/rmgk/maven/de/tuda/stg/rescala_2.11/0.19.0/rescala_2.11-0.19.0.jar ...
[info] [SUCCESSFUL ] de.tuda.stg#rescala_2.11;0.19.0!rescala_2.11.jar (1301ms)
[info] downloading https://dl.bintray.com/pweisenburger/maven/de/tuda/stg/retypecheck_2.11/0.1.0/retypecheck_2.11-0.1.0.jar ...
[info] [SUCCESSFUL ] de.tuda.stg#retypecheck_2.11;0.1.0!retypecheck_2.11.jar (751ms)
[info] downloading https://repo1.maven.org/maven2/org/scalamacros/resetallattrs_2.11/1.0.0/resetallattrs_2.11-1.0.0.jar ...
[info] [SUCCESSFUL ] org.scalamacros#resetallattrs_2.11;1.0.0!resetallattrs_2.11.jar (134ms)
[info] Done updating.
然后你可以import rescala._
然后,您可以在此处尝试基本的Singnal
和Var
示例 - http://guidosalva.github.io/REScala/manual/#signals-and-vars
//
scala> import rescala._
import rescala._
scala> val initialState = Var(28)
initialState: rescala.Var[Int] = <console>(14)
scala> val changeSignal: Signal[Int] = Signal{ initialState() + 1 }
changeSignal: rescala.Signal[Int] = <console>(15)
scala> initialState.now
res1: Int = 28
scala> changeSignal.now
res2: Int = 29
与您关于如何运行scala clickcounter示例的问题相同。进入内部,将rescala.jar放入类路径并运行它,或者只是创建一个build.sbt
并从控制台运行它。