如何运行Rescala程序

时间:2017-03-01 23:37:52

标签: scala

我是Scala的新手,由于一些要求,我需要运行列出here的Rescala(反应式Scala)程序。例如,要运行 clickcounter 应用程序,我该怎么办?任何投入都会有很大的帮助。

1 个答案:

答案 0 :(得分:0)

尝试scala console

// 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.

//

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并从控制台运行它。