Skip to content

Commit bf6e89b

Browse files
Merge pull request #1796 from benjchristensen/testsubject-javadoc
Improve TestSubject Javadoc
2 parents 671c398 + 9bf589d commit bf6e89b

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/main/java/rx/subjects/TestSubject.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.concurrent.TimeUnit;
1919

20+
import rx.Observable;
2021
import rx.Observer;
2122
import rx.Scheduler;
2223
import rx.functions.Action0;
@@ -27,7 +28,8 @@
2728

2829
/**
2930
* 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+
* you to precisely time emissions and notifications to the Subject's subscribers using relative virtual time
32+
* controlled by the {@link TestScheduler}.
3133
*
3234
* @param <T>
3335
* the type of item observed by and emitted by the subject
@@ -66,6 +68,9 @@ protected TestSubject(OnSubscribe<T> onSubscribe, SubjectSubscriptionManager<T>
6668
this.innerScheduler = scheduler.createWorker();
6769
}
6870

71+
/**
72+
* Schedule a call to {@code onCompleted} at relative time of "now()" on TestScheduler.
73+
*/
6974
@Override
7075
public void onCompleted() {
7176
onCompleted(innerScheduler.now());
@@ -80,11 +85,10 @@ private void _onCompleted() {
8085
}
8186

8287
/**
83-
* Schedule a call to the {@code onCompleted} methods of all of the subscribers to this Subject to begin at
84-
* a particular time.
88+
* Schedule a call to {@code onCompleted} relative to "now()" +n milliseconds in the future.
8589
*
8690
* @param timeInMilliseconds
87-
* the time at which to begin calling the {@code onCompleted} methods of the subscribers
91+
* the number of milliseconds in the future relative to "now()" at which to call {@code onCompleted}
8892
*/
8993
public void onCompleted(long timeInMilliseconds) {
9094
innerScheduler.schedule(new Action0() {
@@ -97,6 +101,9 @@ public void call() {
97101
}, timeInMilliseconds, TimeUnit.MILLISECONDS);
98102
}
99103

104+
/**
105+
* Schedule a call to {@code onError} at relative time of "now()" on TestScheduler.
106+
*/
100107
@Override
101108
public void onError(final Throwable e) {
102109
onError(e, innerScheduler.now());
@@ -111,13 +118,12 @@ private void _onError(final Throwable e) {
111118
}
112119

113120
/**
114-
* Schedule a call to the {@code onError} methods of all of the subscribers to this Subject to begin at
115-
* a particular time.
121+
* Schedule a call to {@code onError} relative to "now()" +n milliseconds in the future.
116122
*
117123
* @param e
118-
* the {@code Throwable} to pass to the {@code onError} methods of the subscribers
124+
* the {@code Throwable} to pass to the {@code onError} method
119125
* @param timeInMilliseconds
120-
* the time at which to begin calling the {@code onError} methods of the subscribers
126+
* the number of milliseconds in the future relative to "now()" at which to call {@code onError}
121127
*/
122128
public void onError(final Throwable e, long timeInMilliseconds) {
123129
innerScheduler.schedule(new Action0() {
@@ -130,6 +136,9 @@ public void call() {
130136
}, timeInMilliseconds, TimeUnit.MILLISECONDS);
131137
}
132138

139+
/**
140+
* Schedule a call to {@code onNext} at relative time of "now()" on TestScheduler.
141+
*/
133142
@Override
134143
public void onNext(T v) {
135144
onNext(v, innerScheduler.now());
@@ -142,13 +151,12 @@ private void _onNext(T v) {
142151
}
143152

144153
/**
145-
* Emit an item to all of the subscribers to this Subject at a particular time.
154+
* Schedule a call to {@code onNext} relative to "now()" +n milliseconds in the future.
146155
*
147156
* @param v
148157
* the item to emit
149158
* @param timeInMilliseconds
150-
* the time at which to begin calling the {@code onNext} methods of the subscribers in order to emit
151-
* the item
159+
* the number of milliseconds in the future relative to "now()" at which to call {@code onNext}
152160
*/
153161
public void onNext(final T v, long timeInMilliseconds) {
154162
innerScheduler.schedule(new Action0() {

0 commit comments

Comments
 (0)