我正在尝试包装rxjava的timeout
方法,以使其可用于scala.
与我尝试过的许多其他方法类似:
def timeout[U >: T](timeout: Duration, other: Observable[U]): Observable[U] = { val otherJava: rx.Observable[_ <: U] = other.asJavaObservable val thisJava: rx.Observable[_ <: U] = this.asJavaObservable toScalaObservable[U](thisJava.timeout(timeout.length, timeout.unit, otherJava)) }
但是我收到以下错误:
Observable.scala:1631: error: overloaded method value timeout with alternatives: ($1: Long,x$2: java.util.concurrent.TimeUnit,x$3: rx.Scheduler)rx.Observable[_$85]($1: Long,x$2: java.util.concurrent.TimeUnit,x$3: rx.Observable[_ <: _$85])rx.Observable[_$85] cannot be applied to (Long, scala.concurrent.duration.TimeUnit, rx.Observable[_$84]) toScalaObservable[U](thisJava.timeout(timeout.length, timeout.unit, otherJava))
原始的java方法:
public Observabletimeout(long timeout, TimeUnit timeUnit, Observable extends T> other) { return create(OperationTimeout.timeout(this, timeout, timeUnit, other)); }
我不是很熟悉,没有Java和斯卡拉(和所有类型的边界),但据我的理解:无论otherJava
以及thisJava
类型为rx.Observable[U]
,那么他们为什么不排队?