-
Notifications
You must be signed in to change notification settings - Fork 10
Comparison of Scala Observable and Java Observable
samuelgruetter edited this page Sep 20, 2013
·
1 revision
Note:
- This table contains both static methods and instance methods.
- If a signature is too long, move your mouse over it to get the full signature.
Java Method | Scala Method |
---|---|
aggregate(R, Func2<R, ? super T, R>) |
fold(R)((R, T) => R) |
aggregate(Func2<T, T, T>) |
reduce((U, U) => U) |
all(Func1<? super T, Boolean>) |
forall(T => Boolean) |
average(Observable<Integer>) averageDoubles(Observable<Double>) averageFloats(Observable<Float>) averageLongs(Observable<Long>)
|
We can't have a general average method because Scala's Numeric does not have scalar multiplication (we would need to calculate (1.0/numberOfElements)*sum ). You can use fold instead to accumulate sum and numberOfElements and divide at the end. |
buffer(Int, Int) |
buffer(Int, Int) |
buffer(Long, TimeUnit, Int) |
buffer(Duration, Int) |
buffer(Long, Long, TimeUnit, Scheduler) |
buffer(Duration, Duration, Scheduler) |
buffer(Long, Long, TimeUnit) |
buffer(Duration, Duration) |
buffer(...) |
buffer(Observable[Opening], Opening => Observable[Closing]) |
buffer(...) |
buffer(() => Observable[Closing]) |
buffer(Long, TimeUnit) |
buffer(Duration) |
buffer(Long, TimeUnit, Int, Scheduler) |
buffer(Duration, Int, Scheduler) |
buffer(Int) |
buffer(Int) |
buffer(Long, TimeUnit, Scheduler) |
buffer(Duration, Scheduler) |
cache() |
cache |
combineLatest(...) |
combineLatest(Observable[U]) |
combineLatest(...) combineLatest(...) combineLatest(...) combineLatest(...) combineLatest(...) combineLatest(...) combineLatest(...)
|
If C# doesn't need it, Scala doesn't need it either ;-) |
concat(...) |
concat(<:<[Observable[T], Observable[Observable[U]]]) |
concat(...) concat(...) concat(...) concat(...) concat(...) concat(...) concat(...) concat(...)
|
unnecessary because we can use ++ instead or Observable(o1, o2, ...).concat
|
count() |
length |
create(OnSubscribeFunc<T>) |
apply(Observer[T] => Subscription) |
debounce(Long, TimeUnit) |
debounce(Duration) |
debounce(Long, TimeUnit, Scheduler) |
debounce(Duration, Scheduler) |
defer(Func0<? extends Observable<? extends T>>) |
defer(=> Observable[T]) |
dematerialize() |
dematerialize(<:<[T, Notification[U]]) |
distinct(Comparator<T>) distinct(...)
|
TODO: missing |
distinct(Func1<? super T, ? extends U>) |
distinct(T => U) |
distinct() |
distinct |
distinctUntilChanged() |
distinctUntilChanged |
distinctUntilChanged(Comparator<T>) distinctUntilChanged(...)
|
TODO: missing |
distinctUntilChanged(...) |
distinctUntilChanged(T => U) |
empty() |
apply(T*) |
error(Throwable) |
apply(Throwable) |
filter(Func1<? super T, Boolean>) |
filter(T => Boolean) |
finallyDo(Action0) |
finallyDo(() => Unit) |
first() |
first |
first(Func1<? super T, Boolean>) |
use .filter(condition).first
|
firstOrDefault(Func1<? super T, Boolean>, T) |
use .filter(condition).firstOrElse(default)
|
firstOrDefault(T) |
firstOrElse(=> U) |
flatMap(...) |
flatMap(T => Observable[R]) |
from(Future<? extends T>, Long, TimeUnit) |
apply(Future[T], Duration) |
from(Future<? extends T>) |
apply(Future[T]) |
from(Future<? extends T>, Scheduler) |
apply(Future[T], Scheduler) |
from(T[]) from(Iterable<? extends T>) from(T) from(T, T) from(T, T, T) from(T, T, T, T) from(T, T, T, T, T) from(T, T, T, T, T, T) from(T, T, T, T, T, T, T) from(T, T, T, T, T, T, T, T) from(T, T, T, T, T, T, T, T, T) from(T, T, T, T, T, T, T, T, T, T)
|
apply(T*) |
groupBy(Func1<? super T, ? extends K>) |
groupBy(T => K) |
groupBy(...) |
use groupBy and map
|
interval(Long, TimeUnit) |
interval(Duration) |
interval(Long, TimeUnit, Scheduler) |
interval(Duration, Scheduler) |
just(T) |
just(T) |
map(Func1<? super T, ? extends R>) |
map(T => R) |
mapMany(...) |
flatMap(T => Observable[R]) |
mapWithIndex(...) |
combine zipWithIndex with map or with a for comprehension |
materialize() |
materialize |
merge(...) merge(...) merge(...) merge(...) merge(...) merge(...) merge(...)
|
unnecessary because we can use Observable(o1, o2, ...).flatten instead |
merge(...) |
flatten(<:<[Observable[T], Observable[Observable[U]]]) |
merge(...) |
merge(Observable[U]) |
mergeDelayError(...) |
flattenDelayError(<:<[Observable[T], Observable[Observable[U]]]) |
mergeDelayError(...) mergeDelayError(...) mergeDelayError(...) mergeDelayError(...) mergeDelayError(...) mergeDelayError(...) mergeDelayError(...)
|
unnecessary because we can use Observable(o1, o2, ...).flattenDelayError instead |
mergeDelayError(...) |
mergeDelayError(Observable[U]) |
multicast(Subject<? super T, ? extends R>) |
multicast(Subject[T, R]) |
never() |
never |
observeOn(Scheduler) |
observeOn(Scheduler) |
onErrorResumeNext(...) |
onErrorResumeNext(Throwable => Observable[U]) |
onErrorResumeNext(Observable<? extends T>) |
onErrorResumeNext(Observable[U]) |
onErrorReturn(Func1<Throwable, ? extends T>) |
onErrorReturn(Throwable => U) |
onExceptionResumeNext(Observable<? extends T>) |
onExceptionResumeNext(Observable[U]) |
parallel(Func1<Observable<T>, Observable<R>>) |
parallel(Observable[T] => Observable[R]) |
parallel(...) |
parallel(Observable[T] => Observable[R], Scheduler) |
publish() |
publish |
range(Int, Int) |
apply(Range) |
reduce(Func2<T, T, T>) |
reduce((U, U) => U) |
reduce(R, Func2<R, ? super T, R>) |
fold(R)((R, T) => R) |
replay() |
replay |
retry(Int) |
retry(Int) |
retry() |
retry |
sample(Long, TimeUnit) |
sample(Duration) |
sample(Long, TimeUnit, Scheduler) |
sample(Duration, Scheduler) |
scan(Func2<T, T, T>) |
considered unnecessary in Scala land |
scan(R, Func2<R, ? super T, R>) |
scan(R)((R, T) => R) |
sequenceEqual(...) |
use (first zip second) map (p => equality(p._1, p._2))
|
sequenceEqual(...) |
use (first zip second) map (p => p._1 == p._2)
|
skip(Int) |
drop(Int) |
skipWhile(Func1<? super T, Boolean>) |
dropWhile(T => Boolean) |
skipWhileWithIndex(...) |
considered unnecessary in Scala land |
startWith(Iterable<T>) startWith(T) startWith(T, T) startWith(T, T, T) startWith(T, T, T, T) startWith(T, T, T, T, T) startWith(T, T, T, T, T, T) startWith(T, T, T, T, T, T, T) startWith(T, T, T, T, T, T, T, T) startWith(T, T, T, T, T, T, T, T, T)
|
unnecessary because we can just use ++ instead |
subscribe(Observer<? super T>, Scheduler) |
subscribe(Observer[T], Scheduler) |
subscribe(Action1<? super T>, Action1<Throwable>) |
subscribe(T => Unit, Throwable => Unit) |
subscribe(...) |
subscribe(T => Unit, Throwable => Unit, () => Unit) |
subscribe(...) |
subscribe(T => Unit, Throwable => Unit, () => Unit, Scheduler) |
subscribe(Action1<? super T>) |
subscribe(T => Unit) |
subscribe(...) |
subscribe(T => Unit, Throwable => Unit, Scheduler) |
subscribe(Action1<? super T>, Scheduler) |
subscribe(T => Unit, Scheduler) |
subscribe(Observer<? super T>) |
subscribe(Observer[T]) |
subscribeOn(Scheduler) |
subscribeOn(Scheduler) |
sum(Observable<Integer>) |
sum(Numeric[U]) |
sumDoubles(Observable<Double>) |
sum(Numeric[U]) |
sumFloats(Observable<Float>) |
sum(Numeric[U]) |
sumLongs(Observable<Long>) |
sum(Numeric[U]) |
switchDo(...) |
deprecated in RxJava |
switchOnNext(...) |
switch(<:<[Observable[T], Observable[Observable[U]]]) |
synchronize() synchronize(Observable<T>)
|
synchronize |
take(Int) |
take(Int) |
takeFirst(Func1<? super T, Boolean>) |
use .filter(condition).first
|
takeFirst() |
first |
takeLast(Int) |
takeRight(Int) |
takeUntil(Observable<? extends E>) |
takeUntil(Observable[E]) |
takeWhile(Func1<? super T, Boolean>) |
takeWhile(T => Boolean) |
takeWhileWithIndex(...) |
takeWhileWithIndex((T, Integer) => Boolean) |
throttleFirst(Long, TimeUnit) |
throttleFirst(Duration) |
throttleFirst(Long, TimeUnit, Scheduler) |
throttleFirst(Duration, Scheduler) |
throttleLast(Long, TimeUnit) |
throttleLast(Duration) |
throttleLast(Long, TimeUnit, Scheduler) |
throttleLast(Duration, Scheduler) |
throttleWithTimeout(Long, TimeUnit, Scheduler) |
throttleWithTimeout(Duration, Scheduler) |
throttleWithTimeout(Long, TimeUnit) |
throttleWithTimeout(Duration) |
timestamp() |
timestamp |
toBlockingObservable() |
toBlockingObservable |
toList() |
toSeq |
toSortedList(Func2<? super T, ? super T, Integer>) |
Sorting is already done in Scala's collection library, use .toSeq.map(_.sortWith(f))
|
toSortedList() |
Sorting is already done in Scala's collection library, use .toSeq.map(_.sorted)
|
where(Func1<? super T, Boolean>) |
filter(T => Boolean) |
window(Long, TimeUnit) |
window(Duration) |
window(Long, TimeUnit, Int) |
window(Duration, Int) |
window(Long, Long, TimeUnit, Scheduler) |
window(Duration, Duration, Scheduler) |
window(Int) |
window(Int) |
window(Int, Int) |
window(Int, Int) |
window(Long, Long, TimeUnit) |
window(Duration, Duration) |
window(...) |
window(Observable[Opening], Opening => Observable[Closing]) |
window(...) |
window(() => Observable[Closing]) |
window(Long, TimeUnit, Int, Scheduler) |
window(Duration, Int, Scheduler) |
window(Long, TimeUnit, Scheduler) |
window(Duration, Scheduler) |
zip(...) |
use instance method zip and map
|
zip(...) zip(...)
|
use zip in companion object and map
|
zip(...) zip(...) zip(...) zip(...) zip(...) zip(...) zip(...)
|
considered unnecessary in Scala land |
This table was generated on Fri Sep 20 17:38:03 CEST 2013.
Do not edit. Instead, edit rx.lang.scala.CompletenessTest
.