26
26
import rx .subjects .SubjectSubscriptionManager .SubjectObserver ;
27
27
28
28
/**
29
- * Subject that, once an {@link Observer} has subscribed, publishes all subsequent events to the subscriber.
30
- * <p>
31
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/S.PublishSubject.png">
32
- * <p>
33
- * Example usage:
34
- * <p>
35
- * <pre> {@code
36
-
37
- PublishSubject<Object> subject = PublishSubject.create();
38
- // observer1 will receive all onNext and onCompleted events
39
- subject.subscribe(observer1);
40
- subject.onNext("one");
41
- subject.onNext("two");
42
- // observer2 will only receive "three" and onCompleted
43
- subject.subscribe(observer2);
44
- subject.onNext("three");
45
- subject.onCompleted();
46
-
47
- } </pre>
48
- *
29
+ * A variety of Subject that is useful for testing purposes. It operates on a {@link TestScheduler} and allows
30
+ * you to precisely time emissions and notifications to the Subject's subscribers.
31
+ *
49
32
* @param <T>
50
33
* the type of item observed by and emitted by the subject
51
- * @warn javadoc seems misleading
52
34
*/
53
35
public final class TestSubject <T > extends Subject <T , T > {
54
36
55
37
/**
56
- * @warn javadoc missing
57
- * @return
38
+ * Creates and returns a new {@code TestSubject}.
39
+ *
40
+ * @param <T> the value type
41
+ * @param scheduler a {@link TestScheduler} on which to operate this Subject
42
+ * @return the new {@code TestSubject}
58
43
*/
59
44
public static <T > TestSubject <T > create (TestScheduler scheduler ) {
60
45
final SubjectSubscriptionManager <T > state = new SubjectSubscriptionManager <T >();
@@ -95,8 +80,11 @@ private void _onCompleted() {
95
80
}
96
81
97
82
/**
98
- * @warn javadoc missing
83
+ * Schedule a call to the {@code onCompleted} methods of all of the subscribers to this Subject to begin at
84
+ * a particular time.
85
+ *
99
86
* @param timeInMilliseconds
87
+ * the time at which to begin calling the {@code onCompleted} methods of the subscribers
100
88
*/
101
89
public void onCompleted (long timeInMilliseconds ) {
102
90
innerScheduler .schedule (new Action0 () {
@@ -123,9 +111,13 @@ private void _onError(final Throwable e) {
123
111
}
124
112
125
113
/**
126
- * @warn javadoc missing
114
+ * Schedule a call to the {@code onError} methods of all of the subscribers to this Subject to begin at
115
+ * a particular time.
116
+ *
127
117
* @param e
118
+ * the {@code Throwable} to pass to the {@code onError} methods of the subscribers
128
119
* @param timeInMilliseconds
120
+ * the time at which to begin calling the {@code onError} methods of the subscribers
129
121
*/
130
122
public void onError (final Throwable e , long timeInMilliseconds ) {
131
123
innerScheduler .schedule (new Action0 () {
@@ -150,9 +142,13 @@ private void _onNext(T v) {
150
142
}
151
143
152
144
/**
153
- * @warn javadoc missing
145
+ * Emit an item to all of the subscribers to this Subject at a particular time.
146
+ *
154
147
* @param v
148
+ * the item to emit
155
149
* @param timeInMilliseconds
150
+ * the time at which to begin calling the {@code onNext} methods of the subscribers in order to emit
151
+ * the item
156
152
*/
157
153
public void onNext (final T v , long timeInMilliseconds ) {
158
154
innerScheduler .schedule (new Action0 () {
0 commit comments