88
88
import rx .operators .OperationSum ;
89
89
import rx .operators .OperationSwitch ;
90
90
import rx .operators .OperationSynchronize ;
91
- import rx .operators .OperatorTake ;
92
91
import rx .operators .OperationTakeLast ;
93
92
import rx .operators .OperationTakeUntil ;
94
93
import rx .operators .OperationTakeWhile ;
100
99
import rx .operators .OperationToMap ;
101
100
import rx .operators .OperationToMultimap ;
102
101
import rx .operators .OperationToObservableFuture ;
103
- import rx .operators .OperationToObservableIterable ;
104
- import rx .operators .OperationToObservableList ;
105
- import rx .operators .OperationToObservableSortedList ;
106
102
import rx .operators .OperationUsing ;
107
103
import rx .operators .OperationWindow ;
108
104
import rx .operators .OperationZip ;
105
+ import rx .operators .OperatorFromIterable ;
106
+ import rx .operators .OperatorTake ;
109
107
import rx .operators .OperatorTakeTimed ;
108
+ import rx .operators .OperatorToObservableList ;
109
+ import rx .operators .OperatorToObservableSortedList ;
110
110
import rx .operators .SafeObservableSubscription ;
111
111
import rx .operators .SafeObserver ;
112
112
import rx .plugins .RxJavaObservableExecutionHook ;
159
159
*/
160
160
public class Observable <T > {
161
161
162
+ final Action2 <Observer <? super T >, OperatorSubscription > f ;
163
+
164
+ /**
165
+ * Observable with Function to execute when subscribed to.
166
+ * <p>
167
+ * NOTE: Use {@link #create(OnSubscribeFunc)} to create an Observable
168
+ * instead of this constructor unless you specifically have a need for
169
+ * inheritance.
170
+ *
171
+ * @param onSubscribe
172
+ * {@link OnSubscribeFunc} to be executed when {@link #subscribe(Observer)} is called
173
+ */
174
+ protected Observable (Action2 <Observer <? super T >, OperatorSubscription > f ) {
175
+ this .f = f ;
176
+ }
177
+
162
178
/**
163
179
<<<<<<< HEAD
164
180
* Function interface for work to be performed when an Observable is subscribed to via
@@ -198,11 +214,10 @@ public void add(Subscription s) {
198
214
199
215
}
200
216
201
- final Action2 <Observer <? super T >, OperatorSubscription > f ;
202
-
203
217
private final static RxJavaObservableExecutionHook hook = RxJavaPlugins .getInstance ().getObservableExecutionHook ();
204
218
205
219
/**
220
+ <<<<<<< HEAD
206
221
* Observable with Function to execute when subscribed to.
207
222
* <p>
208
223
* <em>Note:</em> Use {@link #create(OnSubscribeFunc)} to create an Observable, instead of this
@@ -219,6 +234,8 @@ protected Observable(Action2<Observer<? super T>, OperatorSubscription> f) {
219
234
<<<<<<< HEAD
220
235
* Mirror the one Observable in an Iterable of several Observables that first emits an item.
221
236
=======
237
+ =======
238
+ >>>>>>> Bind implementation of fromIterable, toList, toSortedList
222
239
* Creates an Observable that will execute the given function when an {@link Observer} subscribes to it.
223
240
* <p>
224
241
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/create.png">
@@ -257,7 +274,7 @@ public void call(Observer<? super T> o, OperatorSubscription s) {
257
274
258
275
});
259
276
}
260
-
277
+
261
278
public <R > Observable <R > bind (final Func2 <Observer <? super R >, OperatorSubscription , Observer <? super T >> bind ) {
262
279
return new Observable <R >(new Action2 <Observer <? super R >, OperatorSubscription >() {
263
280
@@ -1277,7 +1294,7 @@ public final static <T> Observable<T> from(Future<? extends T> future, Scheduler
1277
1294
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
1278
1295
*/
1279
1296
public final static <T > Observable <T > from (Iterable <? extends T > iterable ) {
1280
- return from ( iterable , Schedulers . immediate ( ));
1297
+ return create ( new OperatorFromIterable < T >( iterable ));
1281
1298
}
1282
1299
1283
1300
/**
@@ -1299,7 +1316,7 @@ public final static <T> Observable<T> from(Iterable<? extends T> iterable) {
1299
1316
* @see <a href="http://msdn.microsoft.com/en-us/library/hh212140.aspx">MSDN: Observable.ToObservable</a>
1300
1317
*/
1301
1318
public final static <T > Observable <T > from (Iterable <? extends T > iterable , Scheduler scheduler ) {
1302
- return create (OperationToObservableIterable . toObservableIterable (iterable , scheduler ) );
1319
+ return create (new OperatorFromIterable < T > (iterable )). subscribeOn ( scheduler );
1303
1320
}
1304
1321
1305
1322
/**
@@ -1644,8 +1661,9 @@ public final static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T
1644
1661
* @return an Observable that emits each item in the source Array
1645
1662
* @see <a href="https://github.com/Netflix/RxJava/wiki/Creating-Observables#from">RxJava Wiki: from()</a>
1646
1663
*/
1647
- public final static <T > Observable <T > from (T [] items ) {
1648
- return from (Arrays .asList (items ));
1664
+ @ SafeVarargs
1665
+ public final static <T > Observable <T > from (T ... t1 ) {
1666
+ return from (Arrays .asList (t1 ));
1649
1667
}
1650
1668
1651
1669
/**
@@ -8190,7 +8208,7 @@ public final BlockingObservable<T> toBlockingObservable() {
8190
8208
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#tolist">RxJava Wiki: toList()</a>
8191
8209
*/
8192
8210
public final Observable <List <T >> toList () {
8193
- return create ( OperationToObservableList . toObservableList ( this ));
8211
+ return bind ( new OperatorToObservableList < T >( ));
8194
8212
}
8195
8213
8196
8214
/**
@@ -8364,7 +8382,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
8364
8382
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#tosortedlist">RxJava Wiki: toSortedList()</a>
8365
8383
*/
8366
8384
public final Observable <List <T >> toSortedList () {
8367
- return create ( OperationToObservableSortedList . toSortedList ( this ));
8385
+ return bind ( new OperatorToObservableSortedList < T >( ));
8368
8386
}
8369
8387
8370
8388
/**
@@ -8381,7 +8399,7 @@ public final Observable<List<T>> toSortedList() {
8381
8399
* @see <a href="https://github.com/Netflix/RxJava/wiki/Mathematical-and-Aggregate-Operators#tosortedlist">RxJava Wiki: toSortedList()</a>
8382
8400
*/
8383
8401
public final Observable <List <T >> toSortedList (Func2 <? super T , ? super T , Integer > sortFunction ) {
8384
- return create ( OperationToObservableSortedList . toSortedList ( this , sortFunction ));
8402
+ return bind ( new OperatorToObservableSortedList < T >( sortFunction ));
8385
8403
}
8386
8404
8387
8405
/**
0 commit comments