17
17
18
18
import java .util .concurrent .TimeUnit ;
19
19
20
+ import rx .Observable ;
20
21
import rx .Observer ;
21
22
import rx .Scheduler ;
22
23
import rx .functions .Action0 ;
27
28
28
29
/**
29
30
* 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}.
31
33
*
32
34
* @param <T>
33
35
* the type of item observed by and emitted by the subject
@@ -66,6 +68,9 @@ protected TestSubject(OnSubscribe<T> onSubscribe, SubjectSubscriptionManager<T>
66
68
this .innerScheduler = scheduler .createWorker ();
67
69
}
68
70
71
+ /**
72
+ * Schedule a call to {@code onCompleted} at relative time of "now()" on TestScheduler.
73
+ */
69
74
@ Override
70
75
public void onCompleted () {
71
76
onCompleted (innerScheduler .now ());
@@ -80,11 +85,10 @@ private void _onCompleted() {
80
85
}
81
86
82
87
/**
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.
85
89
*
86
90
* @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}
88
92
*/
89
93
public void onCompleted (long timeInMilliseconds ) {
90
94
innerScheduler .schedule (new Action0 () {
@@ -97,6 +101,9 @@ public void call() {
97
101
}, timeInMilliseconds , TimeUnit .MILLISECONDS );
98
102
}
99
103
104
+ /**
105
+ * Schedule a call to {@code onError} at relative time of "now()" on TestScheduler.
106
+ */
100
107
@ Override
101
108
public void onError (final Throwable e ) {
102
109
onError (e , innerScheduler .now ());
@@ -111,13 +118,12 @@ private void _onError(final Throwable e) {
111
118
}
112
119
113
120
/**
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.
116
122
*
117
123
* @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
119
125
* @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}
121
127
*/
122
128
public void onError (final Throwable e , long timeInMilliseconds ) {
123
129
innerScheduler .schedule (new Action0 () {
@@ -130,6 +136,9 @@ public void call() {
130
136
}, timeInMilliseconds , TimeUnit .MILLISECONDS );
131
137
}
132
138
139
+ /**
140
+ * Schedule a call to {@code onNext} at relative time of "now()" on TestScheduler.
141
+ */
133
142
@ Override
134
143
public void onNext (T v ) {
135
144
onNext (v , innerScheduler .now ());
@@ -142,13 +151,12 @@ private void _onNext(T v) {
142
151
}
143
152
144
153
/**
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 .
146
155
*
147
156
* @param v
148
157
* the item to emit
149
158
* @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}
152
160
*/
153
161
public void onNext (final T v , long timeInMilliseconds ) {
154
162
innerScheduler .schedule (new Action0 () {
0 commit comments