Skip to content

Commit 2952598

Browse files
Merge pull request #690 from Applied-Duality/benChanges
Fixed Scala bindings
2 parents 352683c + 622b661 commit 2952598

File tree

7 files changed

+53
-26
lines changed

7 files changed

+53
-26
lines changed

language-adaptors/rxjava-scala/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sourceSets {
2323
srcDir 'src/main/scala'
2424
srcDir 'src/test/scala'
2525
srcDir 'src/examples/scala'
26-
srcDir 'src/examples/java'
26+
//srcDir 'src/examples/java'
2727
}
2828
java.srcDirs = []
2929
}
@@ -34,7 +34,7 @@ sourceSets {
3434
// the scala source set:
3535
scala {
3636
srcDir 'src/examples/scala'
37-
srcDir 'src/examples/java'
37+
//srcDir 'src/examples/java'
3838
}
3939
java.srcDirs = []
4040
}

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,38 @@ trait Observable[+T]
18601860
toScalaObservable[T](asJavaObservable.doOnEach(observer.asJavaObserver))
18611861
}
18621862

1863+
/**
1864+
* Invokes an action when the source Observable calls <code>onNext</code>.
1865+
*
1866+
* @param onNext the action to invoke when the source Observable calls <code>onNext</code>
1867+
* @return the source Observable with the side-effecting behavior applied
1868+
*/
1869+
def doOnNext(onNext: T => Unit): Observable[T] = {
1870+
toScalaObservable[T](asJavaObservable.doOnNext(onNext))
1871+
}
1872+
1873+
/**
1874+
* Invokes an action if the source Observable calls <code>onError</code>.
1875+
*
1876+
* @param onError the action to invoke if the source Observable calls
1877+
* <code>onError</code>
1878+
* @return the source Observable with the side-effecting behavior applied
1879+
*/
1880+
def doOnError(onError: Throwable => Unit): Observable[T] = {
1881+
toScalaObservable[T](asJavaObservable.doOnError(onError))
1882+
}
1883+
1884+
/**
1885+
* Invokes an action when the source Observable calls <code>onCompleted</code>.
1886+
*
1887+
* @param onCompleted the action to invoke when the source Observable calls
1888+
* <code>onCompleted</code>
1889+
* @return the source Observable with the side-effecting behavior applied
1890+
*/
1891+
def doOnCompleted(onCompleted: () => Unit): Observable[T] = {
1892+
toScalaObservable[T](asJavaObservable.doOnCompleted(onCompleted))
1893+
}
1894+
18631895
/**
18641896
* Returns an Observable that applies the given function to each item emitted by an
18651897
* Observable.
@@ -1869,9 +1901,7 @@ trait Observable[+T]
18691901
* @return an Observable with the side-effecting behavior applied.
18701902
*/
18711903
def doOnEach(onNext: T => Unit): Observable[T] = {
1872-
toScalaObservable[T](asJavaObservable.doOnEach(
1873-
onNext
1874-
))
1904+
toScalaObservable[T](asJavaObservable.doOnNext(onNext))
18751905
}
18761906

18771907
/**
@@ -1884,10 +1914,7 @@ trait Observable[+T]
18841914
* @return an Observable with the side-effecting behavior applied.
18851915
*/
18861916
def doOnEach(onNext: T => Unit, onError: Throwable => Unit): Observable[T] = {
1887-
toScalaObservable[T](asJavaObservable.doOnEach(
1888-
onNext,
1889-
onError
1890-
))
1917+
toScalaObservable[T](asJavaObservable.doOnEach(Observer(onNext, onError, ()=>{})))
18911918
}
18921919

18931920
/**
@@ -1901,11 +1928,7 @@ trait Observable[+T]
19011928
* @return an Observable with the side-effecting behavior applied.
19021929
*/
19031930
def doOnEach(onNext: T => Unit, onError: Throwable => Unit, onCompleted: () => Unit): Observable[T] = {
1904-
toScalaObservable[T](asJavaObservable.doOnEach(
1905-
onNext,
1906-
onError,
1907-
onCompleted
1908-
))
1931+
toScalaObservable[T](asJavaObservable.doOnEach(Observer(onNext, onError,onCompleted)))
19091932
}
19101933
}
19111934

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/subscriptions/BooleanSubscription.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ private [scala] object BooleanSubscription {
2727
private [scala] class BooleanSubscription private[scala] (boolean: rx.subscriptions.BooleanSubscription)
2828
extends Subscription {
2929

30-
override val asJavaSubscription: rx.subscriptions.BooleanSubscription = new rx.subscriptions.BooleanSubscription() {
30+
override val asJavaSubscription: rx.subscriptions.BooleanSubscription = boolean
31+
}
32+
33+
/*
34+
new rx.subscriptions.BooleanSubscription() {
3135
override def unsubscribe(): Unit = {
3236
if(unsubscribed.compareAndSet(false, true)) {
3337
if(!boolean.isUnsubscribed) { boolean.unsubscribe() }
3438
}
3539
}
3640
override def isUnsubscribed(): Boolean = unsubscribed.get() || boolean.isUnsubscribed
3741
}
38-
}
42+
*/

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/subscriptions/MultiAssignmentSubscription.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ class MultipleAssignmentSubscription private[scala] (override val asJavaSubscrip
4747
/**
4848
* Gets the underlying subscription.
4949
*/
50-
def subscription: Subscription = Subscription(asJavaSubscription.getSubscription)
50+
def subscription: Subscription = Subscription(asJavaSubscription.get)
5151

5252
/**
5353
* Gets the underlying subscription
5454
* @param that the new subscription
5555
* @return the [[rx.lang.scala.subscriptions.MultipleAssignmentSubscription]] itself.
5656
*/
5757
def subscription_=(that: Subscription): this.type = {
58-
asJavaSubscription.setSubscription(that.asJavaSubscription)
58+
asJavaSubscription.set(that.asJavaSubscription)
5959
this
6060
}
6161

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/subscriptions/SerialSubscription.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ class SerialSubscription private[scala] (override val asJavaSubscription: rx.sub
4141
override def isUnsubscribed: Boolean = asJavaSubscription.isUnsubscribed
4242

4343
def subscription_=(value: Subscription): this.type = {
44-
asJavaSubscription.setSubscription(value.asJavaSubscription)
44+
asJavaSubscription.set(value.asJavaSubscription)
4545
this
4646
}
47-
def subscription: Subscription = Subscription(asJavaSubscription.getSubscription)
47+
def subscription: Subscription = Subscription(asJavaSubscription.get)
4848

4949
}
5050

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6793,7 +6793,7 @@ public void onNext(T args) { }
67936793
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnNext()</a>
67946794
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229804.aspx">MSDN: Observable.Do</a>
67956795
*/
6796-
public Observable<T> doOnNext(final Action1<T> onNext) {
6796+
public Observable<T> doOnNext(final Action1<? super T> onNext) {
67976797
Observer<T> observer = new Observer<T>() {
67986798
@Override
67996799
public void onCompleted() { }
@@ -6822,7 +6822,7 @@ public void onNext(T args) {
68226822
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnEach()</a>
68236823
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229307.aspx">MSDN: Observable.Do</a>
68246824
*/
6825-
public Observable<T> doOnEach(final Action1<Notification<T>> onNotification) {
6825+
public Observable<T> doOnEach(final Action1<Notification<? super T>> onNotification) {
68266826
Observer<T> observer = new Observer<T>() {
68276827
@Override
68286828
public void onCompleted() {

rxjava-core/src/test/java/rx/operators/OperationWindowTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ private static <T> List<List<T>> toLists(Observable<Observable<T>> observables)
5050
final List<List<T>> lists = new ArrayList<List<T>>();
5151
Observable.concat(observables.map(new Func1<Observable<T>, Observable<List<T>>>() {
5252
@Override
53-
public Observable<List<T>> call(Observable<T> xs) {
54-
return xs.toList();
55-
}
56-
})).toBlockingObservable().forEach(new Action1<List<T>>() {
53+
public Observable<List<T>> call(Observable<T> xs) { return xs.toList(); }
54+
}))
55+
.toBlockingObservable()
56+
.forEach(new Action1<List<T>>() {
5757
@Override
5858
public void call(List<T> xs) {
5959
lists.add(xs);

0 commit comments

Comments
 (0)