Skip to content

Commit 462dfeb

Browse files
committed
javadocs for Subscriber variants: take care of Observer/Subscriber distinction (ReactiveX#1848)
1 parent d1530a8 commit 462dfeb

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

src/main/java/rx/observers/SafeSubscriber.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
import rx.plugins.RxJavaPlugins;
2626

2727
/**
28-
* Wrapper around {@code Observer} that ensures compliance with the Rx contract.
28+
* {@code SafeSubscriber} is a wrapper around {@code Subscriber} that ensures that the {@code Subscriber}
29+
* complies with the Rx contract.
2930
* <p>
3031
* The following is taken from <a href="http://go.microsoft.com/fwlink/?LinkID=205219">the Rx Design Guidelines
3132
* document</a>:
3233
* <blockquote><p>
3334
* Messages sent to instances of the {@code IObserver} interface follow the following grammar:
3435
* </p><blockquote><p> {@code OnNext* (OnCompleted | OnError)?} </p></blockquote><p>
3536
* This grammar allows observable sequences to send any amount (0 or more) of {@code OnNext} messages to the
36-
* subscribed observer instance, optionally followed by a single success ({@code OnCompleted}) or failure
37-
* ({@code OnError}) message.
37+
* subscriber, optionally followed by a single success ({@code OnCompleted}) or failure ({@code OnError})
38+
* message.
3839
* </p><p>
3940
* The single message indicating that an observable sequence has finished ensures that consumers of the
4041
* observable sequence can deterministically establish that it is safe to perform cleanup operations.
@@ -47,10 +48,10 @@
4748
* <ul>
4849
* <li>Allows only single execution of either {@code onError} or {@code onCompleted}.</li>
4950
* <li>Ensures that once an {@code onCompleted} or {@code onError} is performed, no further calls can be executed</li>
50-
* <li>If {@code unsubscribe} is called, calls {@code completed} and forbids any further {@code onNext} calls.</li>
51-
* <li>When {@code onError} or {@code onComplete} occur, unsubscribes from the {@code Observable} (if executing asynchronously).</li>
51+
* <li>If {@code unsubscribe} is called, calls {@code onCompleted} and forbids any further {@code onNext} calls.</li>
52+
* <li>When {@code onError} or {@code onCompleted} occur, unsubscribes from the {@code Observable} (if executing asynchronously).</li>
5253
* </ul>
53-
* <p> {@code SafeSubscriber} will not synchronize {@code onNext} execution. Use {@link SerializedSubscriber} to do
54+
* {@code SafeSubscriber} will not synchronize {@code onNext} execution. Use {@link SerializedSubscriber} to do
5455
* that.
5556
*
5657
* @param <T>

src/main/java/rx/observers/TestSubscriber.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import rx.Subscriber;
2525

2626
/**
27-
* Subscriber usable for unit testing to perform assertions, inspect received events, or wrap a mocked
28-
* Subscriber.
27+
* A {@code TestSubscriber} is a variety of {@link Subscriber} that you can use for unit testing, to perform
28+
* assertions, inspect received events, or wrap a mocked {@code Subscriber}.
2929
*/
3030
public class TestSubscriber<T> extends Subscriber<T> {
3131

@@ -73,8 +73,8 @@ public void onCompleted() {
7373
}
7474

7575
/**
76-
* Get the {@link Notification}s representing each time this Subscriber was notified of sequence completion
77-
* via {@link #onCompleted}, as a {@link List}.
76+
* Get the {@link Notification}s representing each time this {@link Subscriber} was notified of sequence
77+
* completion via {@link #onCompleted}, as a {@link List}.
7878
*
7979
* @return a list of Notifications representing calls to this Subscriber's {@link #onCompleted} method
8080
*/
@@ -93,7 +93,8 @@ public void onError(Throwable e) {
9393
}
9494

9595
/**
96-
* Get the {@link Throwable}s this Subscriber was notified of via {@link #onError} as a {@link List}.
96+
* Get the {@link Throwable}s this {@link Subscriber} was notified of via {@link #onError} as a
97+
* {@link List}.
9798
*
9899
* @return a list of the Throwables that were passed to this Subscriber's {@link #onError} method
99100
*/
@@ -109,14 +110,16 @@ public void onNext(T t) {
109110

110111
/**
111112
* Allow calling the protected {@link #request(long)} from unit tests.
113+
*
112114
* @param n
115+
* @warn parameter "n" not described
113116
*/
114117
public void requestMore(long n) {
115118
request(n);
116119
}
117120

118121
/**
119-
* Get the sequence of items observed by this Subscriber, as an ordered {@link List}.
122+
* Get the sequence of items observed by this {@link Subscriber}, as an ordered {@link List}.
120123
*
121124
* @return a list of items observed by this Subscriber, in the order in which they were observed
122125
*/
@@ -125,7 +128,7 @@ public List<T> getOnNextEvents() {
125128
}
126129

127130
/**
128-
* Assert that a particular sequence of items was received by this Subscriber in order.
131+
* Assert that a particular sequence of items was received by this {@link Subscriber} in order.
129132
*
130133
* @param items
131134
* the sequence of items expected to have been observed
@@ -174,8 +177,8 @@ public void assertNoErrors() {
174177

175178

176179
/**
177-
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
178-
* {@code onCompleted} or {@code onError} notification).
180+
* Blocks until this {@link Subscriber} receives a notification that the {@code Observable} is complete
181+
* (either an {@code onCompleted} or {@code onError} notification).
179182
*
180183
* @throws RuntimeException
181184
* if the Subscriber is interrupted before the Observable is able to complete
@@ -189,8 +192,8 @@ public void awaitTerminalEvent() {
189192
}
190193

191194
/**
192-
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
193-
* {@code onCompleted} or {@code onError} notification), or until a timeout expires.
195+
* Blocks until this {@link Subscriber} receives a notification that the {@code Observable} is complete
196+
* (either an {@code onCompleted} or {@code onError} notification), or until a timeout expires.
194197
*
195198
* @param timeout
196199
* the duration of the timeout
@@ -208,10 +211,10 @@ public void awaitTerminalEvent(long timeout, TimeUnit unit) {
208211
}
209212

210213
/**
211-
* Blocks until this Subscriber receives a notification that the Observable is complete (either an
212-
* {@code onCompleted} or {@code onError} notification), or until a timeout expires; if the Subscriber
213-
* is interrupted before either of these events take place, this method unsubscribes the Subscriber from the
214-
* Observable).
214+
* Blocks until this {@link Subscriber} receives a notification that the {@code Observable} is complete
215+
* (either an {@code onCompleted} or {@code onError} notification), or until a timeout expires; if the
216+
* Subscriber is interrupted before either of these events take place, this method unsubscribes the
217+
* Subscriber from the Observable).
215218
*
216219
* @param timeout
217220
* the duration of the timeout
@@ -227,7 +230,8 @@ public void awaitTerminalEventAndUnsubscribeOnTimeout(long timeout, TimeUnit uni
227230
}
228231

229232
/**
230-
* Returns the last thread that was in use when an item or notification was received by this Subscriber.
233+
* Returns the last thread that was in use when an item or notification was received by this
234+
* {@link Subscriber}.
231235
*
232236
* @return the {@code Thread} on which this Subscriber last received an item or notification from the
233237
* Observable it is subscribed to

0 commit comments

Comments
 (0)