2

这是来自 scala.rx 文档的示例:

package tutorial.webapp

import rx.core.{Rx, Var}
import rx._
import rx.ops._

import scala.concurrent.Promise
import scala.concurrent.duration._
import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport
import scala.concurrent.ExecutionContext.Implicits.global

/**
 * Created by IDEA on 29/10/15.
 */
object RxAddtionalOps extends JSApp {
  @JSExport
  override def main(): Unit = {
    mapDemo
    filterDemo
    asyncDemo
    async2
    timer1
  }

  def delay1: Unit = {
    val a = Var(10)
    val b = a.delay(250 millis)
    a() = 5
    println(b())
    eventually{
      println(b)
    }
  }
}

编译时我在 sbt 上收到此错误:

[error] /Users/kaiyin/personal_config_bin_files/workspace/scalajsHandson/src/main/scala/tutorial/webapp/RxAddtionalOps.scala:43: not found: value eventually
[error]     eventually{
[error]     ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed 30 oct. 2015 11:15:07

函数从何eventually而来?我错过了任何进口吗?

4

1 回答 1

2

It's defined in utest, which is a author's framework for tests. Since it's a test dependency it doesn't come bundled with scalarx. BTW, the very same functionality presented in scalatest.

于 2015-10-30T11:35:53.743 回答