Skip to content

Commit 97fbcc7

Browse files
Removing Scheduler overloads on operators (for now)
I have some outstanding questions on how these should be implemented (or even why we need them when the 'subscribeOn' operator is far cleaner) so want to remove them for now so they don't make it into the public incorrectly.
1 parent d35b3e7 commit 97fbcc7

File tree

2 files changed

+3
-196
lines changed

2 files changed

+3
-196
lines changed

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

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -779,21 +779,6 @@ public static <T> Observable<T> empty() {
779779
return toObservable(new ArrayList<T>());
780780
}
781781

782-
/**
783-
* Returns an Observable that returns no data to the {@link Observer} and immediately invokes its <code>onCompleted</code> method on the given {@link Scheduler}.
784-
* <p>
785-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/empty.png">
786-
*
787-
* @param <T>
788-
* the type of item emitted by the Observable
789-
* @param {@link Scheduler} The scheduler to send the termination ({@link Observer#onCompleted()} call.
790-
* @return an Observable that returns no data to the {@link Observer} and immediately invokes the {@link Observer}'s <code>onCompleted</code> method
791-
*/
792-
@SuppressWarnings("unchecked")
793-
public static <T> Observable<T> empty(Scheduler scheduler) {
794-
return (Observable<T>) empty().subscribeOn(scheduler);
795-
}
796-
797782
/**
798783
* Returns an Observable that calls <code>onError</code> when an {@link Observer} subscribes to it.
799784
* <p>
@@ -877,22 +862,6 @@ public static <T> Observable<T> from(Iterable<T> iterable) {
877862
return toObservable(iterable);
878863
}
879864

880-
/**
881-
* Converts an {@link Iterable} sequence to an Observable sequence that is subscribed to on the given {@link Scheduler}.
882-
*
883-
* @param iterable
884-
* the source {@link Iterable} sequence
885-
* @param scheduler
886-
* The {@link Scheduler} that the sequence is subscribed to on.
887-
* @param <T>
888-
* the type of items in the {@link Iterable} sequence and the type emitted by the resulting Observable
889-
* @return an Observable that emits each item in the source {@link Iterable} sequence
890-
* @see {@link #toObservable(Iterable)}
891-
*/
892-
public static <T> Observable<T> from(Iterable<T> iterable, Scheduler scheduler) {
893-
return toObservable(iterable, scheduler);
894-
}
895-
896865
/**
897866
* Converts an Array to an Observable sequence.
898867
*
@@ -907,22 +876,6 @@ public static <T> Observable<T> from(T... items) {
907876
return toObservable(items);
908877
}
909878

910-
/**
911-
* Converts an Array to an Observable sequence that is subscribed to on the given {@link Scheduler}.
912-
*
913-
* @param scheduler
914-
* The {@link Scheduler} that the sequence is subscribed to on.
915-
* @param items
916-
* the source Array
917-
* @param <T>
918-
* the type of items in the Array, and the type of items emitted by the resulting Observable
919-
* @return an Observable that emits each item in the source Array
920-
* @see {@link #toObservable(Object...)}
921-
*/
922-
public static <T> Observable<T> from(Scheduler scheduler, T... items) {
923-
return toObservable(scheduler, items);
924-
}
925-
926879
/**
927880
* Generates an observable sequence of integral numbers within a specified range.
928881
*
@@ -1302,25 +1255,6 @@ public static <T> Observable<T> merge(List<Observable<T>> source) {
13021255
return create(OperationMerge.merge(source));
13031256
}
13041257

1305-
/**
1306-
* Flattens the Observable sequences from a list of Observables into one Observable sequence
1307-
* without any transformation. You can combine the output of multiple Observables so that they
1308-
* act like a single Observable, by using the <code>merge</code> method.
1309-
* <p>
1310-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/merge.png">
1311-
*
1312-
* @param source
1313-
* a list of Observables that emit sequences of items
1314-
* @param scheduler
1315-
* The {@link Scheduler} that the sequence is subscribed to on.
1316-
* @return an Observable that emits a sequence of elements that are the result of flattening the
1317-
* output from the <code>source</code> list of Observables
1318-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge</a>
1319-
*/
1320-
public static <T> Observable<T> merge(List<Observable<T>> source, Scheduler scheduler) {
1321-
return merge(source).subscribeOn(scheduler);
1322-
}
1323-
13241258
/**
13251259
* Flattens the Observable sequences emitted by a sequence of Observables that are emitted by a
13261260
* Observable into one Observable sequence without any transformation. You can combine the output
@@ -1338,25 +1272,6 @@ public static <T> Observable<T> merge(Observable<Observable<T>> source) {
13381272
return create(OperationMerge.merge(source));
13391273
}
13401274

1341-
/**
1342-
* Flattens the Observable sequences emitted by a sequence of Observables that are emitted by a
1343-
* Observable into one Observable sequence without any transformation. You can combine the output
1344-
* of multiple Observables so that they act like a single Observable, by using the <code>merge</code> method.
1345-
* <p>
1346-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/merge.png">
1347-
*
1348-
* @param source
1349-
* an Observable that emits Observables
1350-
* @param scheduler
1351-
* The {@link Scheduler} that the sequence is subscribed to on.
1352-
* @return an Observable that emits a sequence of elements that are the result of flattening the
1353-
* output from the Observables emitted by the <code>source</code> Observable
1354-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
1355-
*/
1356-
public static <T> Observable<T> merge(Observable<Observable<T>> source, Scheduler scheduler) {
1357-
return merge(source).subscribeOn(scheduler);
1358-
}
1359-
13601275
/**
13611276
* Flattens the Observable sequences from a series of Observables into one Observable sequence
13621277
* without any transformation. You can combine the output of multiple Observables so that they
@@ -1374,25 +1289,6 @@ public static <T> Observable<T> merge(Observable<T>... source) {
13741289
return create(OperationMerge.merge(source));
13751290
}
13761291

1377-
/**
1378-
* Flattens the Observable sequences from a series of Observables into one Observable sequence
1379-
* without any transformation. You can combine the output of multiple Observables so that they
1380-
* act like a single Observable, by using the <code>merge</code> method.
1381-
* <p>
1382-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/merge.png">
1383-
*
1384-
* @param scheduler
1385-
* The {@link Scheduler} that the sequence is subscribed to on.
1386-
* @param source
1387-
* a series of Observables that emit sequences of items
1388-
* @return an Observable that emits a sequence of elements that are the result of flattening the
1389-
* output from the <code>source</code> Observables
1390-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229099(v=vs.103).aspx">MSDN: Observable.Merge Method</a>
1391-
*/
1392-
public static <T> Observable<T> merge(Scheduler scheduler, Observable<T>... source) {
1393-
return merge(source).subscribeOn(scheduler);
1394-
}
1395-
13961292
/**
13971293
* Returns the values from the source observable sequence until the other observable sequence produces a value.
13981294
*
@@ -2316,27 +2212,6 @@ public static <T> Observable<T> toObservable(Iterable<T> iterable) {
23162212
return create(OperationToObservableIterable.toObservableIterable(iterable));
23172213
}
23182214

2319-
/**
2320-
* Converts an Iterable sequence to an Observable sequence which is subscribed to on the given {@link Scheduler}.
2321-
*
2322-
* Any object that supports the Iterable interface can be converted into an Observable that emits
2323-
* each iterable item in the object, by passing the object into the <code>toObservable</code> method.
2324-
* <p>
2325-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/toObservable.png">
2326-
*
2327-
* @param iterable
2328-
* the source Iterable sequence
2329-
* @param scheduler
2330-
* The {@link Scheduler} that the sequence is subscribed to on.
2331-
* @param <T>
2332-
* the type of items in the iterable sequence and the type emitted by the resulting
2333-
* Observable
2334-
* @return an Observable that emits each item in the source Iterable sequence
2335-
*/
2336-
public static <T> Observable<T> toObservable(Iterable<T> iterable, Scheduler scheduler) {
2337-
return toObservable(iterable).subscribeOn(scheduler);
2338-
}
2339-
23402215
/**
23412216
* Converts an Future to an Observable sequence.
23422217
*
@@ -2356,27 +2231,6 @@ public static <T> Observable<T> toObservable(Future<T> future) {
23562231
return create(OperationToObservableFuture.toObservableFuture(future));
23572232
}
23582233

2359-
/**
2360-
* Converts an Future to an Observable sequence that is subscribed to on the given {@link Scheduler}.
2361-
*
2362-
* Any object that supports the {@link Future} interface can be converted into an Observable that emits
2363-
* the return value of the get() method in the object, by passing the object into the <code>toObservable</code> method.
2364-
* <p>
2365-
* This is blocking so the Subscription returned when calling {@link #subscribe(Observer)} does nothing.
2366-
*
2367-
* @param future
2368-
* the source {@link Future}
2369-
* @param scheduler
2370-
* The {@link Scheduler} to wait for the future on.
2371-
* @param <T>
2372-
* the type of of object that the future's returns and the type emitted by the resulting
2373-
* Observable
2374-
* @return an Observable that emits the item from the source Future
2375-
*/
2376-
public static <T> Observable<T> toObservable(Future<T> future, Scheduler scheduler) {
2377-
return toObservable(future).subscribeOn(scheduler);
2378-
}
2379-
23802234
/**
23812235
* Converts an Future to an Observable sequence.
23822236
*
@@ -2401,32 +2255,6 @@ public static <T> Observable<T> toObservable(Future<T> future, long timeout, Tim
24012255
return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit));
24022256
}
24032257

2404-
/**
2405-
* Converts an Future to an Observable sequence that is subscribed to on the given {@link Scheduler}.
2406-
*
2407-
* Any object that supports the {@link Future} interface can be converted into an Observable that emits
2408-
* the return value of the get() method in the object, by passing the object into the <code>toObservable</code> method.
2409-
* The subscribe method on this synchronously so the Subscription returned doesn't nothing.
2410-
* <p>
2411-
* This is blocking so the Subscription returned when calling {@link #subscribe(Observer)} does nothing.
2412-
*
2413-
* @param future
2414-
* the source {@link Future}
2415-
* @param timeout
2416-
* the maximum time to wait
2417-
* @param unit
2418-
* the time unit of the time argument
2419-
* @param scheduler
2420-
* The {@link Scheduler} to wait for the future on.
2421-
* @param <T>
2422-
* the type of of object that the future's returns and the type emitted by the resulting
2423-
* Observable
2424-
* @return an Observable that emits the item from the source Future
2425-
*/
2426-
public static <T> Observable<T> toObservable(Future<T> future, long timeout, TimeUnit unit, Scheduler scheduler) {
2427-
return toObservable(future, timeout, unit).subscribeOn(scheduler);
2428-
}
2429-
24302258
/**
24312259
* Converts an Array sequence to an Observable sequence.
24322260
*
@@ -2446,27 +2274,6 @@ public static <T> Observable<T> toObservable(T... items) {
24462274
return toObservable(Arrays.asList(items));
24472275
}
24482276

2449-
/**
2450-
* Converts an Array sequence to an Observable sequence which is subscribed to on the given {@link Scheduler}.
2451-
*
2452-
* An Array can be converted into an Observable that emits each item in the Array, by passing the
2453-
* Array into the <code>toObservable</code> method.
2454-
* <p>
2455-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/toObservable.png">
2456-
*
2457-
* @param scheduler
2458-
* The {@link Scheduler} that the sequence is subscribed to on.
2459-
* @param items
2460-
* the source Array
2461-
* @param <T>
2462-
* the type of items in the Array, and the type of items emitted by the resulting
2463-
* Observable
2464-
* @return an Observable that emits each item in the source Array
2465-
*/
2466-
public static <T> Observable<T> toObservable(Scheduler scheduler, T... items) {
2467-
return toObservable(items).subscribeOn(scheduler);
2468-
}
2469-
24702277
/**
24712278
* Sort T objects by their natural order (object must implement Comparable).
24722279
* <p>

rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void testMergeWithImmediateScheduler1() {
115115
Observable<Integer> o1 = Observable.<Integer> from(1, 2, 3, 4, 5);
116116
Observable<Integer> o2 = Observable.<Integer> from(6, 7, 8, 9, 10);
117117
@SuppressWarnings("unchecked")
118-
Observable<String> o = Observable.<Integer> merge(Schedulers.immediate(), o1, o2).map(new Func1<Integer, String>() {
118+
Observable<String> o = Observable.<Integer> merge(o1, o2).subscribeOn(Schedulers.immediate()).map(new Func1<Integer, String>() {
119119

120120
@Override
121121
public String call(Integer t) {
@@ -141,7 +141,7 @@ public void testMergeWithCurrentThreadScheduler1() {
141141
Observable<Integer> o1 = Observable.<Integer> from(1, 2, 3, 4, 5);
142142
Observable<Integer> o2 = Observable.<Integer> from(6, 7, 8, 9, 10);
143143
@SuppressWarnings("unchecked")
144-
Observable<String> o = Observable.<Integer> merge(Schedulers.currentThread(), o1, o2).map(new Func1<Integer, String>() {
144+
Observable<String> o = Observable.<Integer> merge(o1, o2).subscribeOn(Schedulers.currentThread()).map(new Func1<Integer, String>() {
145145

146146
@Override
147147
public String call(Integer t) {
@@ -167,7 +167,7 @@ public void testMergeWithScheduler1() {
167167
Observable<Integer> o1 = Observable.<Integer> from(1, 2, 3, 4, 5);
168168
Observable<Integer> o2 = Observable.<Integer> from(6, 7, 8, 9, 10);
169169
@SuppressWarnings("unchecked")
170-
Observable<String> o = Observable.<Integer> merge(Schedulers.threadPoolForComputation(), o1, o2).map(new Func1<Integer, String>() {
170+
Observable<String> o = Observable.<Integer> merge(o1, o2).subscribeOn(Schedulers.threadPoolForComputation()).map(new Func1<Integer, String>() {
171171

172172
@Override
173173
public String call(Integer t) {

0 commit comments

Comments
 (0)