15
15
import java .util .*;
16
16
import java .util .concurrent .*;
17
17
18
- import rx .annotations .Beta ;
19
- import rx .annotations .Experimental ;
18
+ import rx .annotations .*;
20
19
import rx .exceptions .*;
21
20
import rx .functions .*;
22
21
import rx .internal .operators .*;
23
- import rx .internal .util .ScalarSynchronousObservable ;
24
- import rx .internal .util .UtilityFunctions ;
22
+ import rx .internal .util .*;
25
23
import rx .observables .*;
26
24
import rx .observers .SafeSubscriber ;
27
25
import rx .plugins .*;
@@ -1031,6 +1029,14 @@ public final static <T> Observable<T> defer(Func0<Observable<T>> observableFacto
1031
1029
return create (new OnSubscribeDefer <T >(observableFactory ));
1032
1030
}
1033
1031
1032
+ /** An empty observable which just emits onCompleted to any subscriber. */
1033
+ private static final Observable <Object > EMPTY = create (new OnSubscribe <Object >() {
1034
+ @ Override
1035
+ public void call (Subscriber <? super Object > t1 ) {
1036
+ t1 .onCompleted ();
1037
+ }
1038
+ });
1039
+
1034
1040
/**
1035
1041
* Returns an Observable that emits no items to the {@link Observer} and immediately invokes its
1036
1042
* {@link Observer#onCompleted onCompleted} method.
@@ -1047,8 +1053,9 @@ public final static <T> Observable<T> defer(Func0<Observable<T>> observableFacto
1047
1053
* {@link Observer}'s {@link Observer#onCompleted() onCompleted} method
1048
1054
* @see <a href="http://reactivex.io/documentation/operators/empty-never-throw.html">ReactiveX operators documentation: Empty</a>
1049
1055
*/
1056
+ @ SuppressWarnings ("unchecked" )
1050
1057
public final static <T > Observable <T > empty () {
1051
- return from ( Collections . <T >emptyList ()) ;
1058
+ return ( Observable <T >) EMPTY ;
1052
1059
}
1053
1060
1054
1061
/**
0 commit comments