1515import java .util .*;
1616import java .util .concurrent .*;
1717
18- import rx .annotations .Beta ;
19- import rx .annotations .Experimental ;
18+ import rx .annotations .*;
2019import rx .exceptions .*;
2120import rx .functions .*;
2221import rx .internal .operators .*;
23- import rx .internal .util .ScalarSynchronousObservable ;
24- import rx .internal .util .UtilityFunctions ;
22+ import rx .internal .util .*;
2523import rx .observables .*;
2624import rx .observers .SafeSubscriber ;
2725import rx .plugins .*;
@@ -1031,6 +1029,14 @@ public final static <T> Observable<T> defer(Func0<Observable<T>> observableFacto
10311029 return create (new OnSubscribeDefer <T >(observableFactory ));
10321030 }
10331031
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+
10341040 /**
10351041 * Returns an Observable that emits no items to the {@link Observer} and immediately invokes its
10361042 * {@link Observer#onCompleted onCompleted} method.
@@ -1047,8 +1053,9 @@ public final static <T> Observable<T> defer(Func0<Observable<T>> observableFacto
10471053 * {@link Observer}'s {@link Observer#onCompleted() onCompleted} method
10481054 * @see <a href="http://reactivex.io/documentation/operators/empty-never-throw.html">ReactiveX operators documentation: Empty</a>
10491055 */
1056+ @ SuppressWarnings ("unchecked" )
10501057 public final static <T > Observable <T > empty () {
1051- return from ( Collections . <T >emptyList ()) ;
1058+ return ( Observable <T >) EMPTY ;
10521059 }
10531060
10541061 /**
0 commit comments