Skip to content

Commit 35f20be

Browse files
Commentary on constructing an Observable
- I would like to remove the no-arg constructor but not ready to pull the trigger
1 parent 52640f5 commit 35f20be

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,10 @@ public class Observable<T> {
116116

117117
private final Func1<Observer<T>, Subscription> onSubscribe;
118118

119-
protected Observable() {
120-
this(null);
121-
}
122-
123119
/**
124-
* Construct an Observable with Function to execute when subscribed to.
120+
* Observable with Function to execute when subscribed to.
125121
* <p>
126-
* NOTE: Generally you're better off using {@link #create(Func1)} to create an Observable instead of using inheritance.
122+
* NOTE: Use {@link #create(Func1)} to create an Observable instead of this method unless you specifically have a need for inheritance.
127123
*
128124
* @param onSubscribe
129125
* {@link Func1} to be executed when {@link #subscribe(Observer)} is called.
@@ -132,6 +128,11 @@ protected Observable(Func1<Observer<T>, Subscription> onSubscribe) {
132128
this.onSubscribe = onSubscribe;
133129
}
134130

131+
protected Observable() {
132+
this(null);
133+
//TODO should this be made private to prevent it? It really serves no good purpose and only confuses things. Unit tests are incorrectly using it today
134+
}
135+
135136
/**
136137
* an {@link Observer} must call an Observable's <code>subscribe</code> method in order to register itself
137138
* to receive push-based notifications from the Observable. A typical implementation of the

0 commit comments

Comments
 (0)