Skip to content

Commit 3d77dc9

Browse files
Merge pull request #1229 from benjchristensen/1116-ambiguous-overloads
Remove Ambiguous Subscribe Overloads with Scheduler
2 parents 5ecf69a + 7039d62 commit 3d77dc9

File tree

3 files changed

+2
-170
lines changed

3 files changed

+2
-170
lines changed

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

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ trait Observable[+T]
118118
asJavaObservable.subscribe()
119119
}
120120

121-
/**
122-
* $subscribeObserverMain
123-
*
124-
* @param observer $subscribeObserverParamObserver
125-
* @param scheduler $subscribeObserverParamScheduler
126-
* @return $subscribeAllReturn
127-
*/
128-
def subscribe(observer: Observer[T], scheduler: Scheduler): Subscription = {
129-
asJavaObservable.subscribe(observer.asJavaObserver, scheduler)
130-
}
131-
132121
/**
133122
* $subscribeObserverMain
134123
*
@@ -147,19 +136,6 @@ trait Observable[+T]
147136
*/
148137
def apply(observer: Observer[T]): Subscription = subscribe(observer)
149138

150-
/**
151-
* $subscribeSubscriberMain
152-
*
153-
* @param subscriber $subscribeSubscriberParamObserver
154-
* @param scheduler $subscribeSubscriberParamScheduler
155-
* @return $subscribeAllReturn
156-
*/
157-
def subscribe(subscriber: Subscriber[T], scheduler: Scheduler): Subscription = {
158-
// Add the casting to avoid compile error "ambiguous reference to overloaded definition"
159-
val thisJava = asJavaObservable.asInstanceOf[rx.Observable[T]]
160-
thisJava.subscribe(subscriber.asJavaSubscriber, scheduler)
161-
}
162-
163139
/**
164140
* $subscribeSubscriberMain
165141
*
@@ -220,48 +196,6 @@ trait Observable[+T]
220196
)
221197
}
222198

223-
/**
224-
* $subscribeCallbacksMainWithNotifications
225-
*
226-
* @param onNext $subscribeCallbacksParamOnNext
227-
* @param onError $subscribeCallbacksParamOnError
228-
* @param onCompleted $subscribeCallbacksParamOnComplete
229-
* @param scheduler $subscribeCallbacksParamScheduler
230-
* @return $subscribeAllReturn
231-
*/
232-
def subscribe(onNext: T => Unit, onError: Throwable => Unit, onCompleted: () => Unit, scheduler: Scheduler): Subscription = {
233-
asJavaObservable.subscribe(scalaFunction1ProducingUnitToAction1(onNext),
234-
scalaFunction1ProducingUnitToAction1(onError),
235-
scalaFunction0ProducingUnitToAction0(onCompleted),
236-
scheduler)
237-
}
238-
239-
/**
240-
* $subscribeCallbacksMainWithNotifications
241-
*
242-
* @param onNext $subscribeCallbacksParamOnNext
243-
* @param onError $subscribeCallbacksParamOnError
244-
* @param scheduler $subscribeCallbacksParamScheduler
245-
* @return $subscribeAllReturn
246-
*/
247-
def subscribe(onNext: T => Unit, onError: Throwable => Unit, scheduler: Scheduler): Subscription = {
248-
asJavaObservable.subscribe(
249-
scalaFunction1ProducingUnitToAction1(onNext),
250-
scalaFunction1ProducingUnitToAction1(onError),
251-
scheduler)
252-
}
253-
254-
/**
255-
* $subscribeCallbacksMainNoNotifications
256-
*
257-
* @param onNext $subscribeCallbacksParamOnNext
258-
* @param scheduler $subscribeCallbacksParamScheduler
259-
* @return $subscribeAllReturn
260-
*/
261-
def subscribe(onNext: T => Unit, scheduler: Scheduler): Subscription = {
262-
asJavaObservable.subscribe(scalaFunction1ProducingUnitToAction1(onNext), scheduler)
263-
}
264-
265199
/**
266200
* Returns a pair of a start function and an [[rx.lang.scala.Observable]] that upon calling the start function causes the source Observable to
267201
* push results into the specified subject.

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

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,76 +6026,6 @@ public final void onNext(T args) {
60266026
});
60276027
}
60286028

6029-
/**
6030-
* An {@link Observer} must call an Observable's {@code subscribe} method in order to receive items and
6031-
* notifications from the Observable.
6032-
*
6033-
* @param onNext
6034-
* FIXME FIXME FIXME
6035-
* @param onError
6036-
* FIXME FIXME FIXME
6037-
* @param onComplete
6038-
* FIXME FIXME FIXME
6039-
* @param scheduler
6040-
* FIXME FIXME FIXME
6041-
* @return a {@link Subscription} reference with which the {@link Observer} can stop receiving items before
6042-
* the Observable has finished sending them
6043-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#wiki-onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
6044-
*/
6045-
public final Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete, Scheduler scheduler) {
6046-
return subscribeOn(scheduler).subscribe(onNext, onError, onComplete);
6047-
}
6048-
6049-
/**
6050-
* An {@link Observer} must call an Observable's {@code subscribe} method in order to receive items and
6051-
* notifications from the Observable.
6052-
*
6053-
* @param onNext
6054-
* FIXME FIXME FIXME
6055-
* @param onError
6056-
* FIXME FIXME FIXME
6057-
* @param scheduler
6058-
* FIXME FIXME FIXME
6059-
* @return a {@link Subscription} reference with which the {@link Observer} can stop receiving items before
6060-
* the Observable has finished sending them
6061-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#wiki-onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
6062-
*/
6063-
public final Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError, Scheduler scheduler) {
6064-
return subscribeOn(scheduler).subscribe(onNext, onError);
6065-
}
6066-
6067-
/**
6068-
* An {@link Observer} must call an Observable's {@code subscribe} method in order to receive items and
6069-
* notifications from the Observable.
6070-
*
6071-
* @param onNext
6072-
* FIXME FIXME FIXME
6073-
* @param scheduler
6074-
* FIXME FIXME FIXME
6075-
* @return a {@link Subscription} reference with which the {@link Observer} can stop receiving items before
6076-
* the Observable has finished sending them
6077-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#wiki-onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
6078-
*/
6079-
public final Subscription subscribe(final Action1<? super T> onNext, Scheduler scheduler) {
6080-
return subscribeOn(scheduler).subscribe(onNext);
6081-
}
6082-
6083-
/**
6084-
* An {@link Observer} must subscribe to an Observable in order to receive items and notifications from the
6085-
* Observable.
6086-
*
6087-
* @param observer
6088-
* FIXME FIXME FIXME
6089-
* @param scheduler
6090-
* FIXME FIXME FIXME
6091-
* @return a {@link Subscription} reference with which the {@link Observer} can stop receiving items before
6092-
* the Observable has finished sending them
6093-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable#wiki-onnext-oncompleted-and-onerror">RxJava Wiki: onNext, onCompleted, and onError</a>
6094-
*/
6095-
public final Subscription subscribe(final Observer<? super T> observer, Scheduler scheduler) {
6096-
return subscribeOn(scheduler).subscribe(observer);
6097-
}
6098-
60996029
/**
61006030
* An {@link Observer} must subscribe to an Observable in order to receive items and notifications from the
61016031
* Observable.
@@ -6241,38 +6171,6 @@ public void call() {
62416171
}
62426172
}
62436173

6244-
/**
6245-
* A {@link Subscriber} must call an Observable's {@code subscribe} method in order to receive items and
6246-
* notifications from the Observable.
6247-
* <p>
6248-
* A typical implementation of {@code subscribe} does the following:
6249-
* <ol>
6250-
* <li>It stores a reference to the Subscriber in a collection object, such as a {@code List<T>} object.</li>
6251-
* <li>It returns a reference to the {@link Subscription} interface. This enables Observers to unsubscribe,
6252-
* that is, to stop receiving items and notifications before the Observable stops sending them, which also
6253-
* invokes the Observer's {@link Observer#onCompleted onCompleted} method.</li>
6254-
* </ol><p>
6255-
* An {@code Observable<T>} instance is responsible for accepting all subscriptions and notifying all
6256-
* Subscribers. Unless the documentation for a particular {@code Observable<T>} implementation indicates
6257-
* otherwise, Subscribers should make no assumptions about the order in which multiple Subscribers will
6258-
* receive their notifications.
6259-
* <p>
6260-
* For more information see the
6261-
* <a href="https://github.com/Netflix/RxJava/wiki/Observable">RxJava Wiki</a>
6262-
*
6263-
* @param observer
6264-
* the {@link Subscriber}
6265-
* @param scheduler
6266-
* the {@link Scheduler} on which Subscribers subscribe to the Observable
6267-
* @return a {@link Subscription} reference with which Subscribers that are {@link Observer}s can
6268-
* unsubscribe from the Observable
6269-
* @throws IllegalArgumentException
6270-
* if an argument to {@code subscribe()} is {@code null}
6271-
*/
6272-
public final Subscription subscribe(Subscriber<? super T> observer, Scheduler scheduler) {
6273-
return subscribeOn(scheduler).subscribe(observer);
6274-
}
6275-
62766174
/**
62776175
* Asynchronously subscribes Observers to this Observable on the specified {@link Scheduler}.
62786176
* <p>

rxjava-core/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public void call(Integer t) {
371371
final CountDownLatch latch = new CountDownLatch(5);
372372
final CountDownLatch first = new CountDownLatch(1);
373373

374-
o1.subscribe(new Action1<Integer>() {
374+
o1.subscribeOn(scheduler).subscribe(new Action1<Integer>() {
375375

376376
@Override
377377
public void call(Integer t) {
@@ -388,7 +388,7 @@ public void call(Integer t) {
388388
count.incrementAndGet();
389389
latch.countDown();
390390
}
391-
}, scheduler);
391+
});
392392

393393
// assert we are async
394394
assertEquals(0, count.get());

0 commit comments

Comments
 (0)