File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -1029,13 +1029,15 @@ public final static <T> Observable<T> defer(Func0<Observable<T>> observableFacto
1029
1029
return create (new OnSubscribeDefer <T >(observableFactory ));
1030
1030
}
1031
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
- });
1032
+ /** Lazy initialized Holder for an empty observable which just emits onCompleted to any subscriber. */
1033
+ private static final class EmptyHolder {
1034
+ final static Observable <Object > INSTANCE = create (new OnSubscribe <Object >() {
1035
+ @ Override
1036
+ public void call (Subscriber <? super Object > subscriber ) {
1037
+ subscriber .onCompleted ();
1038
+ }
1039
+ });
1040
+ }
1039
1041
1040
1042
/**
1041
1043
* Returns an Observable that emits no items to the {@link Observer} and immediately invokes its
@@ -1055,7 +1057,7 @@ public void call(Subscriber<? super Object> t1) {
1055
1057
*/
1056
1058
@ SuppressWarnings ("unchecked" )
1057
1059
public final static <T > Observable <T > empty () {
1058
- return (Observable <T >)EMPTY ;
1060
+ return (Observable <T >) EmptyHolder . INSTANCE ;
1059
1061
}
1060
1062
1061
1063
/**
You can’t perform that action at this time.
0 commit comments